4552021-11-03 16:17:56kovacs.peter.18fToronyépítés (1,1,3,3)cpp11Accepted 50/504ms1972 KiB
#include <iostream>

unsigned int N, a, b, c;

int main() {
	std::cin.sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cin >> N;
	switch (N % 3) {
	case 0:
		c = 1;
		break;
	case 1:
		b = 1;
		c = 2;
		break;
	case 2:
		a = 1;
		b = 2;
		c = 4;
		break;
	}
	N -= N % 3;
	while (N > 5) {
		a = 2 * (a + c);
		b = 2 * (b + a);
		c = 2 * (c + b);
		a = 2 * (a + c) % 20210108;
		b = 2 * (b + a) % 20210108;
		c = 2 * (c + b) % 20210108;
		N -= 6;
	}
	if (N) {
		std::cout << 2 * (c + 2 * (b + 2 * (a + c))) % 20210108;
		return 0;
	}
	std::cout << c;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1816 KiB
2Accepted0/02ms1856 KiB
3Accepted3/32ms1920 KiB
4Accepted3/31ms1928 KiB
5Accepted4/41ms1932 KiB
6Accepted4/41ms1932 KiB
7Accepted4/44ms1940 KiB
8Accepted4/41ms1940 KiB
9Accepted4/41ms1944 KiB
10Accepted4/41ms1948 KiB
11Accepted4/42ms1960 KiB
12Accepted4/44ms1964 KiB
13Accepted4/43ms1964 KiB
14Accepted4/42ms1968 KiB
15Accepted2/21ms1968 KiB
16Accepted2/21ms1972 KiB