Submission #20055

# Submission time Handle Problem Language Result Execution time Memory
20055 2016-02-25T08:56:40 Z Namnamseo 카드 (kriii4_Z) C++14
0 / 100
0 ms 87868 KB
#include<cstdio>
#include<cstring>
long long a,b,i,c,aa,bb=1,x,X=int(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(L==0) return D[C][L]=(C==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;
}
int 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);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 87868 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -