Count the number of 0 for each of the two 1, and multiply the numbers by a few +1.
Note two places: will explode int, need to open a long long. All numbers are 0 when the output is 0.
#include <cstdio>#include<cstring>#include<vector>#include<cmath>#include<queue>#include<list>#include<algorithm>using namespacestd;Const intmaxn= -+Ten;intN;intA[maxn];vector<Long Long>v;intMain () {scanf ("%d",&N); Long Longans=0; intfirst=-1, last=-1; for(intI=1; i<=n; i++) scanf ("%d",&A[i]); for(intI=1; i<=n; i++) { if(A[i]) { first=i; Break; } } for(intI=n; i>=1; i--) { if(A[i]) { last=i; Break; } } if(first!=-1) {v.clear (); Long Longnum=0; for(intI=first; i<=last; i++) { if(a[i]==1) {v.push_back (num+1); Num=0; } if(a[i]==0) num++; } } if(v.size () = =0) printf ("0\n"); Else{ans=1; for(intI=0; I<v.size (); i++) ans=ans*V[i]; printf ("%lld\n", ans); } return 0;}
Codeforces 617B Chocolate