-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCDQU5.cpp
executable file
·47 lines (42 loc) · 949 Bytes
/
CDQU5.cpp
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
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define maxN 1000001
#define mod 1000000009
// unhackable custom hash for unordered_map
// Credits : neil
struct custom_hash {
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return x + FIXED_RANDOM;
}
};
ll scores[maxN];
void calcScore() {
scores[0] = 1, scores[1] = 0, scores[2] = 1;
for (int i = 3; i < maxN; i++)
scores[i] += (scores[i - 2] + scores[i - 3]) % mod;
}
void solve() {
ll x;
cin >> x;
cout << scores[x] << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
calcScore();
cin >> t;
while (t--)
solve();
return 0;
}