#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,dp[3004][3004],mod=1000000007LL;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
dp[1][0]=1;
for(i=1; i<a; i++){
for(j=0; j<=min(b,i-1); j++){
dp[i+1][j]+=dp[i][j]*(j+1);
dp[i+1][j]%=mod;
dp[i+1][j+1]+=dp[i][j]*(i-j);
dp[i+1][j+1]%=mod;
}
}
cout<<dp[a][b-1];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
748 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
2 ms |
1772 KB |
Output is correct |
15 |
Correct |
2 ms |
1900 KB |
Output is correct |
16 |
Correct |
2 ms |
1900 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
2 ms |
1644 KB |
Output is correct |
19 |
Correct |
2 ms |
1004 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
748 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
2 ms |
1772 KB |
Output is correct |
15 |
Correct |
2 ms |
1900 KB |
Output is correct |
16 |
Correct |
2 ms |
1900 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
2 ms |
1644 KB |
Output is correct |
19 |
Correct |
2 ms |
1004 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
4332 KB |
Output is correct |
22 |
Correct |
3 ms |
4332 KB |
Output is correct |
23 |
Correct |
10 ms |
7148 KB |
Output is correct |
24 |
Correct |
11 ms |
7276 KB |
Output is correct |
25 |
Correct |
13 ms |
8288 KB |
Output is correct |
26 |
Correct |
13 ms |
8332 KB |
Output is correct |
27 |
Correct |
12 ms |
8300 KB |
Output is correct |
28 |
Correct |
6 ms |
4204 KB |
Output is correct |
29 |
Correct |
1 ms |
1252 KB |
Output is correct |
30 |
Correct |
12 ms |
8172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
748 KB |
Output is correct |
12 |
Correct |
1 ms |
1388 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
2 ms |
1772 KB |
Output is correct |
15 |
Correct |
2 ms |
1900 KB |
Output is correct |
16 |
Correct |
2 ms |
1900 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
2 ms |
1644 KB |
Output is correct |
19 |
Correct |
2 ms |
1004 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
4332 KB |
Output is correct |
22 |
Correct |
3 ms |
4332 KB |
Output is correct |
23 |
Correct |
10 ms |
7148 KB |
Output is correct |
24 |
Correct |
11 ms |
7276 KB |
Output is correct |
25 |
Correct |
13 ms |
8288 KB |
Output is correct |
26 |
Correct |
13 ms |
8332 KB |
Output is correct |
27 |
Correct |
12 ms |
8300 KB |
Output is correct |
28 |
Correct |
6 ms |
4204 KB |
Output is correct |
29 |
Correct |
1 ms |
1252 KB |
Output is correct |
30 |
Correct |
12 ms |
8172 KB |
Output is correct |
31 |
Runtime error |
55 ms |
25068 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |