Submission #2122416
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<=5000000;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 | Huruohan |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 759 Byte |
Status | WA |
Exec Time | 182 ms |
Memory | 148992 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 | 132 ms | 118272 KB |
0_01.txt | WA | 126 ms | 118272 KB |
0_02.txt | AC | 124 ms | 118272 KB |
0_03.txt | AC | 174 ms | 148992 KB |
1_00.txt | AC | 129 ms | 118272 KB |
1_01.txt | AC | 123 ms | 118272 KB |
1_02.txt | WA | 145 ms | 148992 KB |
1_03.txt | AC | 171 ms | 148992 KB |
1_04.txt | AC | 164 ms | 148992 KB |
1_05.txt | AC | 164 ms | 148992 KB |
1_06.txt | AC | 182 ms | 148992 KB |
1_07.txt | AC | 162 ms | 148992 KB |
1_08.txt | AC | 164 ms | 148992 KB |
1_09.txt | AC | 165 ms | 148992 KB |
1_10.txt | AC | 166 ms | 148992 KB |
1_11.txt | AC | 160 ms | 148992 KB |
1_12.txt | AC | 128 ms | 127488 KB |
1_13.txt | AC | 170 ms | 146944 KB |
1_14.txt | AC | 131 ms | 120960 KB |
1_15.txt | AC | 132 ms | 131840 KB |
1_16.txt | AC | 147 ms | 138368 KB |
1_17.txt | AC | 159 ms | 146944 KB |
1_18.txt | AC | 134 ms | 123136 KB |
1_19.txt | AC | 166 ms | 148992 KB |