This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<cstring>
long long a,b,i,c,aa,bb=1,x,X=1e9+7,D[3333][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]=1;
if(L==0)return D[C][L]=0;
if(C>L)return D[C][L]=0;
if(C==1&&L==1)return D[C][L]=1;
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);if(x==1)c++;};
if(c==0)
{
printf("1");
return 0;
}
aa=f(c,b);
for(i=1;i<=b;i++)bb*=a,bb%=X;
printf("%lld",aa*pow(bb,X-2)%X);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |