Submission #2122390
Source Code Expand
#include <bits/stdc++.h> #define LL long long #define MOD 1000000007 using namespace std; int N,K; LL fac[5000010],inv[5000010],ifac[5000010],d[2010][2010]; int main() { cin>>N>>K; fac[0]=inv[0]=ifac[0]=fac[1]=inv[1]=ifac[1]=1; for(int i=2;i<=1000000;i++) { fac[i]=(fac[i-1]*i)%MOD; inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD; ifac[i]=(ifac[i-1]*inv[i])%MOD; } d[0][1]=1; for(int i=2;i<=N;i++) { d[0][i]=d[0][i-1]*(fac[i*(K-1)-1]*ifac[K-2]%MOD*ifac[(i-1)*(K-1)]%MOD)%MOD; } for(int i=1;i<=N;i++) { for(int j=i;j<=N;j++) { d[i][j]=(d[i-1][j]+d[i][j-1]*(fac[i+j*(K-1)-1]*ifac[K-2]%MOD*ifac[i+(j-1)*(K-1)]%MOD))%MOD; // cout<<i<<' '<<j<<' '<<d[i][j]<<endl; } } cout<<(d[N][N]*fac[N])%MOD<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Leftmost Ball |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 728 Byte |
Status | WA |
Exec Time | 50 ms |
Memory | 61696 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1600 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 20 ms | 30976 KB |
0_01.txt | WA | 19 ms | 30976 KB |
0_02.txt | AC | 20 ms | 30976 KB |
0_03.txt | WA | 50 ms | 61696 KB |
1_00.txt | AC | 20 ms | 30976 KB |
1_01.txt | AC | 20 ms | 30976 KB |
1_02.txt | WA | 40 ms | 61696 KB |
1_03.txt | WA | 50 ms | 61696 KB |
1_04.txt | WA | 46 ms | 61696 KB |
1_05.txt | WA | 45 ms | 61696 KB |
1_06.txt | WA | 48 ms | 61696 KB |
1_07.txt | WA | 43 ms | 61696 KB |
1_08.txt | WA | 46 ms | 61696 KB |
1_09.txt | WA | 46 ms | 61696 KB |
1_10.txt | WA | 49 ms | 61696 KB |
1_11.txt | WA | 46 ms | 61696 KB |
1_12.txt | AC | 25 ms | 40192 KB |
1_13.txt | WA | 44 ms | 59648 KB |
1_14.txt | AC | 21 ms | 33664 KB |
1_15.txt | WA | 28 ms | 44544 KB |
1_16.txt | WA | 36 ms | 51072 KB |
1_17.txt | WA | 45 ms | 59648 KB |
1_18.txt | AC | 22 ms | 35840 KB |
1_19.txt | WA | 47 ms | 61696 KB |