Submission #2122429
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; if(K==1) { cout<<1<<endl; return 0; } 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 | A - Range Product |
User | Huruohan |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 809 Byte |
Status | RE |
Exec Time | 404 ms |
Memory | 118272 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | 0 / 100 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask1 | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 126 ms | 118272 KB |
0_01.txt | RE | 404 ms | 118272 KB |
0_02.txt | WA | 1 ms | 256 KB |
1_00.txt | WA | 127 ms | 118272 KB |
1_01.txt | RE | 218 ms | 118272 KB |
1_02.txt | RE | 227 ms | 118272 KB |
1_03.txt | RE | 219 ms | 118272 KB |
2_00.txt | RE | 217 ms | 118272 KB |
2_01.txt | RE | 219 ms | 118272 KB |
2_02.txt | RE | 220 ms | 118272 KB |
2_03.txt | RE | 222 ms | 118272 KB |