Task: | Torni |
Sender: | ArktinenKarpalo |
Submission time: | 2020-09-25 20:09:47 +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 <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define M 1000000007 using namespace std; ll ab[22][22]; ll ans[1010101]; int t; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); ab[0][0] = 1; cin >> t; ll tasa = 0; ll allpair = 0; int cur = 2; ab[cur-1][cur-1] = 1; for(int i=1; i<=1000000; i++) { tasa += ab[cur-1][cur-1]; if(i) { allpair += ab[cur-1][cur-2]; allpair += ab[cur-2][cur-1]; } allpair += ab[cur-1][cur-1]; ab[cur][cur-1] = allpair; ab[cur-1][cur] = allpair; ab[cur-1][cur]%=M; ab[cur][cur-1]%=M; ab[cur][cur] += allpair; ab[cur][cur] += tasa; ab[cur][cur]%=M; allpair %=M; tasa%=M; ans[i] = ab[cur][cur]; ans[i]%=M; /* for(int a=0; a<i; a++) { for(int b=0; b<i; b++) { ab[i][i] += ab[a][b]; ab[i][i] %= M; ab[i][a] += ab[b][a]; ab[a][i] += ab[a][b]; ab[i][a] %= M; ab[a][i] %= M; } }*/ for(int j=2; j>=0; j--) { for(int k=j; k>=0; k--) { ab[cur-j][cur-k] = ab[cur-j+1][cur-k+1]; ab[cur-k][cur-j] = ab[cur-k+1][cur-j+1]; } } } /*for(int g=0; g<t; g++) { int f; cin >> f; cout << ab[f][f] << "\n"; }*/ int f; for(int i=0; i<t; i++) { cin >> f; cout << ans[f]<<"\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: ACCEPTED
input |
---|
100 996306 650655 896240 821967 ... |
correct output |
---|
87350005 606189151 122595036 193572715 227926807 ... |
user output |
---|
87350005 606189151 122595036 193572715 227926807 ... Truncated |