标签:
N<= 20
#include<iostream> #include<cstdio> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int n,ans,s[25]; inline int read() { int a=0,f=1; char c=getchar(); while (c<‘0‘||c>‘9‘) {if (c==‘-‘) f=-1; c=getchar();} while (c>=‘0‘&&c<=‘9‘) {a=a*10+c-‘0‘; c=getchar();} return a*f; } int main() { n=read(); for (int i=1;i<=n;i++) { int x=read(); s[i]=s[i-1]+x; } for (int i=1;i<=n;i++) for (int j=i+1;j<=n;j++) for (int k=j+1;k<=n;k++) for (int l=k+1;l<=n;l++) if (s[j]-s[i]==s[l]-s[k]&&s[n]-s[l]+s[i]==s[k]-s[j]) ans++; printf("%d",ans); return 0; }
[AHOI2009][BZOJ1800] fly 飞行棋|枚举|暴力
标签:
原文地址:http://www.cnblogs.com/ws-fqk/p/4737366.html