3802021-11-03 08:18:14hentesoposszumToronyépítés (1,1,3,3)cpp11Accepted 50/5012ms9444 KiB
#include <iostream>
#include <vector>

using namespace std;

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

	int n;
	cin >> n;

	vector<int> b(n + 1);

	b[1] = 2;
	b[2] = 4;
	b[3] = 10;

	if (n < 4) {
		cout << b[n] << endl;
		return 0;
	}

	for (int i = 4; i <= n; i++) {
		b[i] = (2 * b[i - 1] + 2 * b[i - 3]) % 20210108;
	}

	cout << b[n] << endl;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1756 KiB
2Accepted0/01ms1788 KiB
3Accepted3/31ms1840 KiB
4Accepted3/31ms1840 KiB
5Accepted4/41ms1840 KiB
6Accepted4/41ms1836 KiB
7Accepted4/412ms9440 KiB
8Accepted4/43ms2684 KiB
9Accepted4/41ms1840 KiB
10Accepted4/41ms1840 KiB
11Accepted4/43ms3200 KiB
12Accepted4/412ms9444 KiB
13Accepted4/49ms8532 KiB
14Accepted4/44ms4240 KiB
15Accepted2/21ms1840 KiB
16Accepted2/21ms1840 KiB