6672021-11-07 10:42:07TSomaToronyépítés (2,2,3,3)cpp14Accepted 40/402ms2020 KiB
#include <iostream>

using namespace std;

long long N, i, a, b, c, d;
long long const P = 20210108;

int main()
{
	cin >> N;
	if (N == 1) cout << 0;
	else if (N == 2) cout << 2;
	else if (N == 3) cout << 2;
	else
	{
		a = 0;
		b = 2;
		c = 2;
		for (i = 4; i <= N; ++i)
		{
			d = (2 * (a + b)) % P;
			a = b;
			b = c;
			c = d;
		}

		cout << d;
	}

	cout << '\n';

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1864 KiB
2Accepted0/01ms1908 KiB
3Accepted2/21ms1976 KiB
4Accepted2/21ms1976 KiB
5Accepted3/31ms1976 KiB
6Accepted3/31ms1980 KiB
7Accepted3/32ms1988 KiB
8Accepted3/32ms1992 KiB
9Accepted3/32ms1992 KiB
10Accepted3/31ms1996 KiB
11Accepted3/32ms2004 KiB
12Accepted3/32ms2008 KiB
13Accepted4/42ms2016 KiB
14Accepted4/42ms2012 KiB
15Accepted2/21ms2016 KiB
16Accepted2/21ms2020 KiB