#include <bits/stdc++.h>
using namespace std ;
const int mod = 1e9 + 7 ;
int Add(int x , int y)
{
int z = x + y ;
if(z >= mod)
z -= mod ;
return z ;
}
int Sub(int x , int y)
{
int z = x - y ;
if(z < 0)
z += mod ;
return z ;
}
int Mul(int x , int y)
{
return (x * 1ll * y) % mod ;
}
int powlog(int base , int power)
{
if(power == 0)
return 1 ;
int x = powlog(base , power / 2) ;
x = Mul(x , x) ;
if(power & 1)
x = Mul(x , base) ;
return x ;
}
int modinv(int x)
{
return powlog(x , mod-2) ;
}
int Div(int x , int y)
{
return Mul(x , modinv(y)) ;
}
const int MAX = 3000 + 10 ;
int arr[MAX] ;
int n , k ;
int dp[MAX][MAX] ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n>>k ;
dp[0][0] = 1 ;
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= k ; ++j)
dp[i][j] = Add(Mul(dp[i-1][j-1] , i-j+1) , Mul(dp[i-1][j] , j)) ;
}
return cout<<dp[n][k]<<"\n" , 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
2 ms |
1620 KB |
Output is correct |
15 |
Correct |
2 ms |
1748 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
1 ms |
832 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
2 ms |
1620 KB |
Output is correct |
15 |
Correct |
2 ms |
1748 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
1 ms |
832 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
4308 KB |
Output is correct |
22 |
Correct |
2 ms |
4296 KB |
Output is correct |
23 |
Correct |
4 ms |
6100 KB |
Output is correct |
24 |
Correct |
5 ms |
6228 KB |
Output is correct |
25 |
Correct |
8 ms |
8020 KB |
Output is correct |
26 |
Correct |
10 ms |
8148 KB |
Output is correct |
27 |
Correct |
8 ms |
8276 KB |
Output is correct |
28 |
Correct |
3 ms |
3924 KB |
Output is correct |
29 |
Correct |
1 ms |
1108 KB |
Output is correct |
30 |
Correct |
10 ms |
8020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
2 ms |
1620 KB |
Output is correct |
15 |
Correct |
2 ms |
1748 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
1 ms |
1492 KB |
Output is correct |
19 |
Correct |
1 ms |
832 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
4308 KB |
Output is correct |
22 |
Correct |
2 ms |
4296 KB |
Output is correct |
23 |
Correct |
4 ms |
6100 KB |
Output is correct |
24 |
Correct |
5 ms |
6228 KB |
Output is correct |
25 |
Correct |
8 ms |
8020 KB |
Output is correct |
26 |
Correct |
10 ms |
8148 KB |
Output is correct |
27 |
Correct |
8 ms |
8276 KB |
Output is correct |
28 |
Correct |
3 ms |
3924 KB |
Output is correct |
29 |
Correct |
1 ms |
1108 KB |
Output is correct |
30 |
Correct |
10 ms |
8020 KB |
Output is correct |
31 |
Runtime error |
42 ms |
25016 KB |
Execution killed with signal 11 |
32 |
Halted |
0 ms |
0 KB |
- |