标签:
N<= 20
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int tot,n,dist[25],ans; int main() { int x; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&x); dist[i]=dist[i-1]+x; tot+=x; } for(int a=1;a<=n;a++) { for(int b=a+1;b<=n;b++) { for(int c=b+1;c<=n;c++) { for(int d=c+1;d<=n;d++) { if(dist[b]-dist[a]==dist[d]-dist[c]&&tot-dist[d]+dist[a]==dist[c]-dist[b]) ans++; } } } } printf("%d\n",ans); return 0; }
标签:
原文地址:http://www.cnblogs.com/water-full/p/4523719.html