Task: | Torni |
Sender: | Metabolix |
Submission time: | 2020-09-25 20:09:27 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 41 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.03 s | 2, 3 | details |
#3 | ACCEPTED | 0.03 s | 3 | details |
Code
#include <iostream> #include <algorithm> #include <vector> const int MOD = 1000000007; const int MAX = 1000009; long tapoja2[MAX], tapoja12[MAX]; int main() { long tapoja1 = 1, tapoja2_sum = 0, tapoja12_sum = 0, haxum = 0; for (long n = 1; n < MAX; ++n) { tapoja2[n] = 1 + tapoja2_sum + tapoja12_sum; tapoja2[n] %= MOD; tapoja2_sum += tapoja2[n]; tapoja2_sum %= MOD; haxum *= 4; haxum += tapoja2[n - 1]; haxum %= MOD; tapoja12[n] = haxum + tapoja1; tapoja1 = (tapoja1 * 4) % MOD; tapoja12[n] %= MOD; tapoja12_sum += tapoja12[n]; tapoja12_sum %= MOD; } int t; std::cin >> t; for (int i = 0; i < t; ++i) { int n; std::cin >> n; std::cout << ((tapoja2[n] + tapoja12[n]) % MOD) << std::endl; } }
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: ACCEPTED
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: ACCEPTED
input |
---|
100 996306 650655 896240 821967 ... |
correct output |
---|
87350005 606189151 122595036 193572715 227926807 ... |
user output |
---|
87350005 606189151 122595036 193572715 227926807 ... Truncated |