Submission #20064

#TimeUsernameProblemLanguageResultExecution timeMemory
20064Namnamseo카드 (kriii4_Z)C++14
0 / 100
0 ms524288 KiB
#include<cstdio> #include<cstring> long long po[33333],a,b,i,c,aa,bb=1,x,X=1e9+7,D[33333][3333]; long long pow(long long aa,long long bb){ if(bb==0) return 1; long long ret=pow(aa,bb/2); ret=(ret*ret)%X; if(bb&1) ret=(ret*aa)%X; return ret; } long long f(long long C,long long L) { if(D[C][L]>=0)return D[C][L]; if(C==0&&L>=0)return D[C][L]=po[L]; if(L==0)return D[C][L]=0; if(C>L)return D[C][L]=0; return D[C][L]=(C*f(C-1,L-1)%X+(a-C)*f(C,L-1)%X)%X; } main() { memset(D,-1,sizeof(D)); scanf("%lld%lld",&a,&b); for(i=1;i<=a;i++){scanf("%lld",&x);c+=x;}; if(c==0) { printf("1"); return 0; } po[0]=1; for(i=1;i<=b;i++)po[i]=po[i-1]*a%X; aa=f(c,b); printf("%lld",aa*pow(po[b],X-2)%X); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...