Task: | Torni |
Sender: | Olli |
Submission time: | 2020-09-26 14:27:12 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 15 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#3 | RUNTIME ERROR | 0.01 s | 3 | details |
Code
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const int M = 1e9 + 7; const int N = 2e3 + 5; ll ans[N]; ll s[N]; ll po[N]; ll s2[N]; int main() { po[0] = 1; po[1] = 1; for(int i = 2; i < N; ++i) { po[i] = 4*po[i-1]; po[i] %= M; } ans[0] = 1; s[0] = 1; for(int i = 1; i < N; ++i) { if(i <= 3) { for(int j = 1; j < i; ++j) { s2[i] += po[j]*s[i-j-1]; s2[i] %= M; } } else { s2[i] = s2[i-1]*4; s2[i] %= M; s2[i] += s[i-2]; s2[i] %= M; } ans[i] = s[i-1] + s2[i] + po[i]; if(ans[i] >= M) ans[i] -= M; s[i] = s[i-1] + ans[i]; s[i] %= M; } int t; cin >> t; for(int i = 1; i <= t; ++i) { int n; cin >> n; cout << ans[n] << "\n"; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
10 1 2 3 4 ... |
correct output |
---|
2 8 34 148 650 ... |
user output |
---|
2 8 34 148 650 ... |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
100 1 2 3 4 ... |
correct output |
---|
2 8 34 148 650 ... |
user output |
---|
2 8 34 148 650 ... Truncated |
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100 996306 650655 896240 821967 ... |
correct output |
---|
87350005 606189151 122595036 193572715 227926807 ... |
user output |
---|
(empty) |