#include <iostream>
using namespace std;
using ll = long long;
const ll mod = 1'000'007LL;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
ll* ch[1+n];
ch[0] = new ll[1+n];
ch[1] = new ll[1+n];
for(int i = 2; i <= n; i++) ch[i] = ch[i-2];
for(int i = 0; i <= n; i++) ch[0][i] = ch[1][i] = 0;
ch[0][0] = 1;
ll dp[1+n];
dp[0] = 1;
for(int i = 1; i <= n; i++)
{
dp[i] = 0;
for(int t = 1; t <= i; t++)
{
// dp[i] = (dp[i] + ((dp[i-t] * ch[i-1][t-1]) % mod)) % mod;
dp[i] = (dp[i] + ((dp[i-t] * ch[i-1][t-1]) % mod)) % mod;
}
ch[i][0] = ch[i][i] = 1;
for(int j = 1; j < i; j++) ch[i][j] = (ch[i-1][j] + ch[i-1][j-1]) % mod;
}
cout << dp[n] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
313 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
296 ms |
616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |