-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboj.10422.cc
50 lines (42 loc) · 899 Bytes
/
boj.10422.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef const ll cll;
typedef queue<ll> qll;
typedef queue<pll> qpll;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll> pqpll;
typedef vector<ll> vll;
cll MAX_DP = 1e9 + 7;
ll t, l, dp[5001] = {};
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
memset(dp, -1, sizeof(dp));
dp[0] = 1, dp[1] = 0, dp[2] = 1;
for (ll i = 3; i <= 5000; ++i)
{
dp[i] = 0;
if (i % 2)
{
continue;
}
for (ll l = i - 2; l >= 0; --l)
{
dp[i] += dp[l] * dp[i - l - 2],
dp[i] %= MAX_DP;
}
}
cin >> t;
while (t--)
{
cin >> l;
cout << dp[l] << "\n";
}
return 0;
}