Submission #22682

#TimeUsernameProblemLanguageResultExecution timeMemory
22682현우야 이거 플로우야 (#40)Unifying Values (KRIII5_UV)C++11
0 / 7
500 ms1312 KiB
#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 { 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; } cnt[k]+=cnt[k-1]; if(j==n) { res=(res+cnt[k])%mod; } } } } } printf("%lld\n",res); return 0; }

Compilation message (stderr)

UV.cpp: In function 'int main()':
UV.cpp:41:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if((sum[j]>0&&sum[i]>0||sum[j]<0&&sum[i]<0)&&sum[j]%sum[i]==0) {
                 ^
UV.cpp:23:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
UV.cpp:25:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",sum+i);
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...