bzoj1800 飞行棋

 

脑筋急转弯。

提示:矩形矩形矩形。O(n)O(n)O(n)。

 

再提示:直角。

 

再提示:直径。

 

代码:

//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=20+5;
int n,a[maxn],tot,sum;

int aa;char cc;
int read() {
	aa=0;cc=getchar();
	while(cc<'0'||cc>'9') cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	return aa;
}

int main() {
	n=read();
	for(int i=1;i<=n;++i) a[i]=read(),tot+=a[i];
	if(tot&1) {
		printf("0");
		return 0;
	}
	else tot>>=1;
	int t=0,now=0;
	for(int pos=1;pos<=n;++pos) {
		while(now<tot) {
			t=t%n+1; now+=a[t];
		}
		if(now==tot) sum++;
		now-=a[pos];
	}
	sum/=2;
	printf("%d",sum*(sum-1)/2);
	return 0;
}

  

转载于:https://www.cnblogs.com/Serene-shixinyi/p/7608105.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值