CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Torni
Sender:FooBat
Submission time:2020-09-27 13:22:00 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED15
#2ACCEPTED41
#3ACCEPTED44
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s2, 3details
#3ACCEPTED0.26 s3details

Code

#include <iostream>
#include <cinttypes>

uint64_t calc(int n) 
{
	uint64_t nx, x = 1;
	uint64_t ny, y = 1;
	uint64_t mod = 1000000000 + 7;
	for (int i = 1; i < n; i++) 
	{
		nx = 2 * x + y;
		ny = x + 4 * y;

		x = nx % mod;
		y = ny % mod;
	}
	return (x + y) % mod;
}

int main()
{
	int tests;
	std::cin >> tests;
	for (int i = 0; i < tests; i++) 
	{
		int n;
		std::cin >> n;
		std::cout << calc(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: 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