CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Torni
Sender:Ender
Submission time:2020-09-26 17:26:30 +0300
Language:C++ (C++11)
Status:READY
Result:15
Feedback
groupverdictscore
#1ACCEPTED15
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details

Code

#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int M = 1e9+7;
int k[101010];

int mod(int a)
{
	return (a%M + M) % M;
}

int f(int a)
{
	if(a<0) return 0;
	if(k[a]) return k[a];

	k[a] = mod(((6*f(a-1))-(7*f(a-2)))%M);

	return k[a];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	k[0] = 1;
	k[1] = 2;
	k[2] = 8;


	int t; cin >> t;

	while(t--)
	{
		int n; cin >> n;
		cout << f(n) << "\n";
	}


	return 0;
}

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:

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:

input
100
996306
650655
896240
821967
...

correct output
87350005
606189151
122595036
193572715
227926807
...

user output
(empty)