1800: [Ahoi2009]fly 飞行棋
来源:互联网 发布:外国人万能的淘宝 编辑:程序博客网 时间:2024/05/31 19:54
1800: [Ahoi2009]fly 飞行棋
Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1332 Solved: 1084
[Submit][Status][Discuss]
Description
给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。
Input
第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度
Output
所构成不重复矩形的个数
Sample Input
8
1
2
2
3
1
1
3
3
1
2
2
3
1
1
3
3
Sample Output
3
HINT
N<= 20
Source
矩形 = 三个直角的四边形
直角 = 半圆弧对应的圆周角
果然枚举是最开心的
#include<iostream>#include<cstdio>#include<cstring>#include<vector>#include<queue>#include<stack>#include<cstdlib>#include<cmath>#include<algorithm>#include<bitset>using namespace std;const int maxn = 25;int n,ans,tot,a[maxn],now[10];bool check(int x){int po = 1,sum = 0;for (; x; x >>= 1) {if (x&1) now[++sum] = po;++po;}return sum == 4;}int main(){#ifdef DMCfreopen("DMC.txt","r",stdin);#endifcin >> n;for (int i = 1; i <= n; i++) scanf("%d",&a[i]),tot += a[i];for (int i = 0; i < (1<<n); i++)if (check(i)) {int sum = 0;for (int j = now[1]; j < now[3]; j++) sum += a[j];if (sum * 2 != tot) continue;sum = 0;for (int j = now[2]; j < now[4]; j++) sum += a[j];if (sum * 2 != tot) continue;sum = 0;for (int j = now[3]; j <= n; j++) sum += a[j];for (int j = 1; j < now[1]; j++) sum += a[j];if (sum * 2 != tot) continue;++ans; }cout << ans;return 0;}
0 0
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- bzoj 1800 [Ahoi2009] fly 飞行棋
- BZOJ 1800 AHOI2009 fly 飞行棋 暴力
- BZOJ 1800 [Ahoi2009]fly 飞行棋
- 【BZOJ 1800】[Ahoi2009]fly 飞行棋
- bzoj 1800: [Ahoi2009]fly 飞行棋
- BZOJ 1800: [Ahoi2009]fly 飞行棋
- [Ahoi2009]fly 飞行棋
- 【BZOJ1800】【Ahoi2009】fly 飞行棋
- [BZOJ1800][Ahoi2009]fly飞行棋
- 【AHOI2009】【BZOJ1800】fly 飞行棋
- [BZOJ1800] [Ahoi2009]fly 飞行棋
- BZOJ1800: [Ahoi2009]fly 飞行棋
- bzoj1800: [Ahoi2009]fly 飞行棋
- [源码学习][知了开发]WebMagic-OOSpider
- HDOJ 1047 Integer Inquiry(多个大数相加)
- HDOJ 1232 畅通工程(并查集)
- Linux学习笔记之守护进程
- malloc,realloc,calloc的介绍与区别
- 1800: [Ahoi2009]fly 飞行棋
- 计蒜客- 简单斐波那契
- Android Activity的四大启动模式
- UVA-591 Box of Bricks
- 克鲁斯卡尔算法+普里姆算法 详解
- 【bzoj2286】 消耗战
- 迪杰斯特拉算法
- 各种android定时器验证
- cocos creator 运用预制件和配置文件添加对象