Submission #23145

#TimeUsernameProblemLanguageResultExecution timeMemory
23145aintaUnifying Values (KRIII5_UV)C++14
7 / 7
99 ms1232 KiB
/*#include<cstdio> #include<algorithm> using namespace std; int P[110], Mod = 1000000007, n, w[60], Comb[5110][110], C[110][110]; int D[51][5010], sum; int main(){ int i, j, k; for(i=0;i<=5101;i++){ Comb[i][0]=1; for(j=1;j<=100&&j<=i;j++){ Comb[i][j]=(Comb[i-1][j-1]+Comb[i-1][j])%Mod; } } for(i=1;i<=100;i++){ int s = 0; for(j=1;j<i;j++){ s = (s + 1ll * P[j]*(i-j))%Mod; } P[i] = (i - s + Mod)%Mod; } C[0][0] = 1; for(i=0;i<100;i++){ for(j=0;j<=100;j++){ for(k=0;k+j<=100;k++){ C[j+k][i+1] = (C[j+k][i+1] + 1ll * C[j][i] * P[k])%Mod; } } } scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&w[i]); D[0][0] = 1; for(i=1;i<=n;i++){ for(j=0;j<=sum;j++){ for(k=1;k<=w[i];k++){ D[i][j+k] = (D[i][j+k] + 1ll * Comb[j+k][k] * C[w[i]][k] % Mod * D[i-1][j])%Mod; } } sum += w[i]; } int ss = 0; int res = 0; for(i=0;i<=sum;i++)res = (res + D[n][i])%Mod; printf("%d\n",res); }*/ #include<cstdio> #include<algorithm> using namespace std; int n, D[10100], Mod = 1000000007, Res; long long S[10100]; void Do(int K){ int i; long long t = S[n]/K, tp; for(i=0;i<=K;i++)D[i] = 0; D[0] = 1; for(i=1;i<=n;i++){ tp = S[i]/t; if(tp*t!=S[i])continue; if(tp<=0||tp>K)continue; D[tp] = (D[tp]+D[tp-1])%Mod; } Res = (Res + D[K-1])%Mod; } int main(){ int i; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%lld",&S[i]); S[i]+=S[i-1]; } if(S[n]==0){ Res = 1; for(i=1;i<n;i++){ if(S[i]==0)Res=Res*2%Mod; } Res=(Res-1)%Mod; printf("%d\n",Res); return 0; } for(i=2;i<=n;i++){ if(S[n]%i==0){ Do(i); } } printf("%d\n",Res); }

Compilation message (stderr)

UV.cpp: In function 'int main()':
UV.cpp:65:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
UV.cpp:67:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&S[i]);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...