Codeforces 21C Stripe 2 slot. The speaker's mother tongue is definitely not English.
Sum = sigma num [I] (1 <= I <= n ).
S [I] = sigam num [j] (1 <= j <= I ).
Find all the values that meet s [I] * 2 = sum-s [I], s [I] = 2 * (sum-s [I]). Then accumulate the enumerated values.
Slot, but the meaning clearly indicates that positive interge is required for each piece.
However, this restriction is enough.
#include #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#pragma comment(linker, "/STACK:1024000000");#define EPS (1e-6)#define _LL long long#define ULL unsigned long long#define LL __int64#define INF 0x3f3f3f3f#define Mod 1000000007/** I/O Accelerator Interface .. **/#define g (c=getchar())#define d isdigit(g)#define p x=x*10+c-'0'#define n x=x*10+'0'-c#define pp l/=10,p#define nn l/=10,ntemplate
inline T& RD(T &x){ char c; while(!d); x=c-'0'; while(d)p; return x;}template
inline T& RDD(T &x){ char c; while(g,c!='-'&&!isdigit(c)); if (c=='-') { x='0'-g; while(d)n; } else { x=c-'0'; while(d)p; } return x;}inline double& RF(double &x) //scanf("%lf", &x);{ char c; while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.') { x=0; double l=1; while(d)nn; x*=l; } else { x='0'-c; while(d)n; if(c=='.') { double l=1; while(d)nn; x*=l; } } else if(c=='.') { x=0; double l=1; while(d)pp; x*=l; } else { x=c-'0'; while(d)p; if(c=='.') { double l=1; while(d)pp; x*=l; } } return x;}#undef nn#undef pp#undef n#undef p#undef d#undef gusing namespace std;LL num[100010];LL ans[2][100010] = {{0},{0}};LL sum[2][100010] = {{0},{0}};LL dis[100010] = {0};int mark[2][100010] = {{0},{0}};int main(){ int n; scanf("%d",&n); int i; for(i = 1;i <= n; ++i) scanf("%I64d",&num[i]); for(i = 1;i <= n; ++i) sum[0][i] = sum[0][i-1] + num[i]; for(i = n;i >= 1; --i) sum[1][i] = sum[1][i+1] + num[i]; for(i = 1;i <= n; ++i) ans[0][i] = ans[0][i-1] + (num[i] >= 0 ? 1 : 0); for(i = n;i >= 1; --i) ans[1][i] = ans[1][i+1] + (num[i] >= 0 ? 1 : 0); LL S = sum[0][n]; for(i = 1;i <= n; ++i) if(sum[0][i]*2 == S-sum[0][i] ) mark[0][i] = 1; for(i = n;i >= 1; --i) if(sum[1][i]*2 == S-sum[1][i]) mark[1][i] = 1; for(i = 1;i <= n; ++i) dis[i] = dis[i-1] + mark[0][i]; LL anw = 0; for(i = 2;i <= n; ++i) if(mark[1][i]) anw += dis[i-2]; printf("%I64d\n",anw); return 0;}