Submission #20058

# Submission time Handle Problem Language Result Execution time Memory
20058 2016-02-25T08:57:41 Z Namnamseo 카드 (kriii4_Z) C++14
13 / 100
137 ms 87912 KB
#include<cstdio>
#include<cstring>
long long po[3333],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]=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);if(x==1)c++;};
    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 time Memory Grader output
1 Correct 81 ms 87908 KB Output is correct
2 Correct 106 ms 87908 KB Output is correct
3 Correct 0 ms 87896 KB Output is correct
4 Correct 103 ms 87904 KB Output is correct
5 Correct 117 ms 87900 KB Output is correct
6 Correct 51 ms 87896 KB Output is correct
7 Correct 127 ms 87896 KB Output is correct
8 Correct 105 ms 87896 KB Output is correct
9 Correct 71 ms 87904 KB Output is correct
10 Correct 80 ms 87896 KB Output is correct
11 Correct 120 ms 87904 KB Output is correct
12 Correct 64 ms 87900 KB Output is correct
13 Correct 106 ms 87896 KB Output is correct
14 Correct 137 ms 87904 KB Output is correct
15 Correct 11 ms 87896 KB Output is correct
16 Correct 85 ms 87896 KB Output is correct
17 Correct 127 ms 87904 KB Output is correct
18 Correct 103 ms 87896 KB Output is correct
19 Correct 17 ms 87912 KB Output is correct
20 Correct 102 ms 87896 KB Output is correct
21 Correct 8 ms 87912 KB Output is correct
22 Correct 12 ms 87912 KB Output is correct
23 Correct 4 ms 87912 KB Output is correct
24 Correct 7 ms 87908 KB Output is correct
25 Correct 4 ms 87908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 118 ms 87900 KB Output isn't correct
2 Halted 0 ms 0 KB -