# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22711 | 2017-04-30T06:47:10 Z | 현우야 이거 플로우야(#903, waylight3, pinebananais, ae04071) | Unifying Values (KRIII5_UV) | C++11 | 6 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 k=sum[j]/sum[i]; if(k>n||k==1) continue; if(chk[k-1]!=i) continue; if(chk[k]!=i) { chk[k]=i; cnt[k]=0; } if(i==7) printf("%d\n",j); cnt[k]+=cnt[k-1]; } } if(chk[k-1]!=i) continue; res=(res+cnt[k])%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 | Incorrect | 3 ms | 1312 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |