Task: | Torni |
Sender: | Guuber |
Submission time: | 2020-09-26 12:27:43 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 56 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 41 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.18 s | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:15:49: warning: iteration 101010 invokes undefined behavior [-Waggressive-loop-optimizations] for(int i = 0; i < 1010101; i++) dp2[i] = 0; ~~~~~~~^~~ input/code.cpp:15:26: note: within this loop for(int i = 0; i < 1010101; i++) dp2[i] = 0; ~~^~~~~~~~~
Code
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll big = 1e9+7; ll dp[1010101]; ll dp2[101010]; int main(){ ll t; cin >> t; while(t--){ ll n; cin >> n; for(int i = 0; i < 1010101; i++) dp[i] = 0; for(int i = 0; i < 1010101; i++) dp2[i] = 0; dp[1] = 1; dp2[1] = 1; for(int i = 2; i <= n; i++){ dp2[i] = 4*dp2[i-1] + dp[i-1]; dp[i] = dp2[i-1] + 2*dp[i-1]; dp2[i] %= big; dp[i] %= big; } cout << (dp[n] + dp2[n])%big << "\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: 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: TIME LIMIT EXCEEDED
input |
---|
100 996306 650655 896240 821967 ... |
correct output |
---|
87350005 606189151 122595036 193572715 227926807 ... |
user output |
---|
(empty) |