#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int MOD=1e9+7;
int dp[3005][3005];
int main()
{
#ifdef HOME
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k,i,j;
cin>>n>>k;
dp[0][0]=1;
for(i=0; i<=n; i++)
for(j=0; j<=k; j++)
{
dp[i+1][j]=(dp[i+1][j]+1LL*j*dp[i][j])%MOD;
dp[i+1][j+1]=(dp[i+1][j+1]+1LL*(i+1-j)*dp[i][j])%MOD;
}
cout<<dp[n][k];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1664 KB |
Output is correct |
15 |
Correct |
2 ms |
1920 KB |
Output is correct |
16 |
Correct |
2 ms |
1920 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1664 KB |
Output is correct |
15 |
Correct |
2 ms |
1920 KB |
Output is correct |
16 |
Correct |
2 ms |
1920 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4352 KB |
Output is correct |
23 |
Correct |
7 ms |
6144 KB |
Output is correct |
24 |
Correct |
7 ms |
6272 KB |
Output is correct |
25 |
Correct |
10 ms |
8064 KB |
Output is correct |
26 |
Correct |
11 ms |
8320 KB |
Output is correct |
27 |
Correct |
11 ms |
8320 KB |
Output is correct |
28 |
Correct |
5 ms |
4096 KB |
Output is correct |
29 |
Correct |
1 ms |
1152 KB |
Output is correct |
30 |
Correct |
11 ms |
8064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1664 KB |
Output is correct |
15 |
Correct |
2 ms |
1920 KB |
Output is correct |
16 |
Correct |
2 ms |
1920 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4352 KB |
Output is correct |
23 |
Correct |
7 ms |
6144 KB |
Output is correct |
24 |
Correct |
7 ms |
6272 KB |
Output is correct |
25 |
Correct |
10 ms |
8064 KB |
Output is correct |
26 |
Correct |
11 ms |
8320 KB |
Output is correct |
27 |
Correct |
11 ms |
8320 KB |
Output is correct |
28 |
Correct |
5 ms |
4096 KB |
Output is correct |
29 |
Correct |
1 ms |
1152 KB |
Output is correct |
30 |
Correct |
11 ms |
8064 KB |
Output is correct |
31 |
Runtime error |
53 ms |
24952 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |