Submission #10302941
Source Code Expand
#include<bits/stdc++.h>
#define Rg register
#define i60 long long
#define fp( i , x , y ) for(Rg int i=(x); i<=(y); ++i)
#define fq( i , x , y ) for(Rg int i=(y); i>=(x); --i)
using namespace std ;
const int hgs = 1e9+7 , N = 2005 ;
i60 f[N][N] , n , k , fac[N*N] , inv[N*N] ;
i60 power( i60 A , int B ) {
i60 tep = 1 ;
for( ; B ; B >>= 1 ) {
if( B&1 ) tep = tep * A % hgs ;
A = A * A % hgs ;
} return tep ; }
i60 C ( int A , int B ) { return A == 0 ? 1 : fac[B] * inv[A] % hgs * inv[B-A] % hgs ; }
signed main( ) {
cin >> n >> k ; fac[0] = 1 ;
if( k == 1 ) { cout << 1 << endl ; return 0 ; }
fp( i , 1 , n*k ) fac[i] = fac[i-1] * i % hgs ;
fp( i , 0 , n*k ) inv[i] = power( fac[i] , hgs-2 ) ;
fp( i , 1 , n ) f[i][0] = 1 ;
fp( i , 1 , n )
fp( j , 1 , i )
f[i][j] = ( f[i-1][j] + f[i][j-1]
* (n-j+1) % hgs * C( k-2 , n*k-i-(k-1)*(j-1)-1 ) ) % hgs ;
cout << f[n][n] << endl ;
return 0 ;
}
Submission Info
Submission Time |
|
Task |
F - Leftmost Ball |
User |
luogu_bot3 |
Language |
C++ (GCC 5.4.1) |
Score |
1600 |
Code Size |
1018 Byte |
Status |
AC |
Exec Time |
683 ms |
Memory |
94464 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1600 / 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 |
2 ms |
4352 KB |
0_01.txt |
AC |
2 ms |
4352 KB |
0_02.txt |
AC |
2 ms |
4352 KB |
0_03.txt |
AC |
683 ms |
94464 KB |
1_00.txt |
AC |
2 ms |
4352 KB |
1_01.txt |
AC |
2 ms |
4352 KB |
1_02.txt |
AC |
2 ms |
4352 KB |
1_03.txt |
AC |
683 ms |
94464 KB |
1_04.txt |
AC |
633 ms |
94464 KB |
1_05.txt |
AC |
652 ms |
94464 KB |
1_06.txt |
AC |
669 ms |
94464 KB |
1_07.txt |
AC |
617 ms |
94464 KB |
1_08.txt |
AC |
634 ms |
94464 KB |
1_09.txt |
AC |
654 ms |
94464 KB |
1_10.txt |
AC |
627 ms |
94464 KB |
1_11.txt |
AC |
653 ms |
94464 KB |
1_12.txt |
AC |
158 ms |
28928 KB |
1_13.txt |
AC |
562 ms |
86272 KB |
1_14.txt |
AC |
19 ms |
7168 KB |
1_15.txt |
AC |
174 ms |
35072 KB |
1_16.txt |
AC |
304 ms |
51456 KB |
1_17.txt |
AC |
433 ms |
71936 KB |
1_18.txt |
AC |
23 ms |
11392 KB |
1_19.txt |
AC |
672 ms |
94464 KB |