Task: | Torni |
Sender: | kluopaja |
Submission time: | 2020-09-26 21:21:02 +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.02 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.02 s | 2, 3 | details |
#3 | ACCEPTED | 0.02 s | 3 | details |
Code
#include <iostream> #include <iomanip> using namespace std; typedef long long ll; const ll MOD = 1e9+7; const int N_MAX = 1e6+10; // dp1[i] == number of towers of length i starting with |___| ll dp1[N_MAX]; // dp2[i] == number of towers of length i starting with |_|_| ll dp2[N_MAX]; int main() { // sum{1 <= j <= i}(2^(2*(j-1))*dp1[i-j]) ll dp1_sum = 1; // sum{1 <= j <= i}(2^(j-1)*dp2[i-j]) ll dp2_sum = 1; for(int i = 1; i < N_MAX; ++i) { dp1[i] = dp2_sum; dp2[i] = dp1_sum; dp1_sum *= 4; dp1_sum += dp1[i]; dp1_sum %= MOD; dp2_sum *= 2; dp2_sum += dp2[i]; dp2_sum %= MOD; } int n; cin>>n; for(int i = 0; i < n; ++i) { int x; cin>>x; cout<<(dp1[x] + dp2[x])%MOD<<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 |