# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22760 | 2017-04-30T07:15:37 Z | 현우야 이거 플로우야(#903, waylight3, pinebananais, ae04071) | Unifying Values (KRIII5_UV) | C++11 | 446 ms | 1312 KB |
#include <stdio.h> typedef long long lli; const lli mod=1e9+7; int n; lli sum[10001]; int chk[10001]; lli cnt[10001]; lli pow(lli a, lli p) { lli res=1; while(p) { if(p&1) res=(res*a)%mod; a=(a*a)%mod; p>>=1; } return res; } int main() { lli zsum=0; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",sum+i); sum[i]+=sum[i-1]; if(sum[i]==0) ++zsum; } --zsum; lli res=0; for(int i=1;i<n;i++) { if(sum[i]==0) { --zsum; if(sum[n]!=0) continue; res=(res+pow(2,zsum))%mod; } else { if((sum[n]>0&&sum[i]>0||sum[n]<0&&sum[i]<0)&&sum[n]%sum[i]!=0) continue; lli k=sum[n]/sum[i]; if(k==1||k>n) continue; cnt[1]=1; chk[1]=i; for(int j=i+1;j<=n;j++) { if((sum[j]>0&&sum[i]>0||sum[j]<0&&sum[i]<0)&&sum[j]%sum[i]==0) { lli kk=sum[j]/sum[i]; if(kk>=k||kk==1) continue; if(chk[kk-1]!=i) continue; if(chk[kk]!=i) { chk[kk]=i; cnt[kk]=0; } cnt[kk]=(cnt[kk]+cnt[kk-1])%mod; } } if(chk[k-1]!=i) continue; res=(res+cnt[k-1])%mod; } } printf("%lld\n",res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1312 KB | Output is correct |
2 | Correct | 0 ms | 1312 KB | Output is correct |
3 | Correct | 0 ms | 1312 KB | Output is correct |
4 | Correct | 3 ms | 1312 KB | Output is correct |
5 | Correct | 3 ms | 1312 KB | Output is correct |
6 | Correct | 0 ms | 1312 KB | Output is correct |
7 | Correct | 3 ms | 1312 KB | Output is correct |
8 | Correct | 3 ms | 1312 KB | Output is correct |
9 | Correct | 0 ms | 1312 KB | Output is correct |
10 | Correct | 49 ms | 1312 KB | Output is correct |
11 | Correct | 13 ms | 1312 KB | Output is correct |
12 | Correct | 236 ms | 1312 KB | Output is correct |
13 | Correct | 6 ms | 1312 KB | Output is correct |
14 | Correct | 6 ms | 1312 KB | Output is correct |
15 | Correct | 3 ms | 1312 KB | Output is correct |
16 | Correct | 6 ms | 1312 KB | Output is correct |
17 | Correct | 6 ms | 1312 KB | Output is correct |
18 | Correct | 189 ms | 1312 KB | Output is correct |
19 | Correct | 446 ms | 1312 KB | Output is correct |
20 | Correct | 439 ms | 1312 KB | Output is correct |
21 | Correct | 339 ms | 1312 KB | Output is correct |
22 | Correct | 269 ms | 1312 KB | Output is correct |
23 | Correct | 226 ms | 1312 KB | Output is correct |
24 | Correct | 229 ms | 1312 KB | Output is correct |
25 | Correct | 179 ms | 1312 KB | Output is correct |
26 | Correct | 169 ms | 1312 KB | Output is correct |
27 | Correct | 113 ms | 1312 KB | Output is correct |
28 | Correct | 216 ms | 1312 KB | Output is correct |
29 | Correct | 173 ms | 1312 KB | Output is correct |
30 | Correct | 23 ms | 1312 KB | Output is correct |
31 | Correct | 19 ms | 1312 KB | Output is correct |
32 | Correct | 23 ms | 1312 KB | Output is correct |
33 | Correct | 173 ms | 1312 KB | Output is correct |
34 | Correct | 49 ms | 1312 KB | Output is correct |
35 | Correct | 46 ms | 1312 KB | Output is correct |
36 | Correct | 53 ms | 1312 KB | Output is correct |
37 | Correct | 69 ms | 1312 KB | Output is correct |
38 | Correct | 76 ms | 1312 KB | Output is correct |
39 | Correct | 99 ms | 1312 KB | Output is correct |
40 | Correct | 26 ms | 1312 KB | Output is correct |
41 | Correct | 23 ms | 1312 KB | Output is correct |
42 | Correct | 9 ms | 1312 KB | Output is correct |
43 | Correct | 33 ms | 1312 KB | Output is correct |
44 | Correct | 29 ms | 1312 KB | Output is correct |
45 | Correct | 46 ms | 1312 KB | Output is correct |
46 | Correct | 49 ms | 1312 KB | Output is correct |
47 | Correct | 16 ms | 1312 KB | Output is correct |
48 | Correct | 16 ms | 1312 KB | Output is correct |
49 | Correct | 6 ms | 1312 KB | Output is correct |
50 | Correct | 9 ms | 1312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 1312 KB | Output is correct |
2 | Correct | 3 ms | 1312 KB | Output is correct |
3 | Correct | 0 ms | 1312 KB | Output is correct |
4 | Correct | 49 ms | 1312 KB | Output is correct |
5 | Correct | 86 ms | 1312 KB | Output is correct |
6 | Correct | 39 ms | 1312 KB | Output is correct |
7 | Correct | 16 ms | 1312 KB | Output is correct |
8 | Correct | 3 ms | 1312 KB | Output is correct |
9 | Correct | 66 ms | 1312 KB | Output is correct |
10 | Correct | 3 ms | 1312 KB | Output is correct |
11 | Correct | 46 ms | 1312 KB | Output is correct |
12 | Correct | 46 ms | 1312 KB | Output is correct |
13 | Runtime error | 0 ms | 1312 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Halted | 0 ms | 0 KB | - |