1800: [Ahoi2009]fly 飞行棋

1800: [Ahoi2009]fly 飞行棋

Time Limit: 10 Sec   Memory Limit: 64 MB
Submit: 1332   Solved: 1084
[ Submit][ Status][ Discuss]

Description

给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列。 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形。

Input

第一行为正整数N,表示点的个数,接下来N行分别为这N个点所分割的各个圆弧长度

Output

所构成不重复矩形的个数

Sample Input

8
1
2
2
3
1
1
3
3


Sample Output

3

HINT

N<= 20

Source

[ Submit][ Status][ Discuss]




矩形 = 三个直角的四边形

直角 = 半圆弧对应的圆周角

果然枚举是最开心的

#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 DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值