3842021-11-03 08:20:50JaksicsPéterToronyépítés (1,1,3,3)cpp11Accepted 50/5016ms17428 KiB
#include <iostream>
#include <vector>

using namespace std;

int torony(int);

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

	int n;
	cin >> n;
	/*
	for (int i = 1; i <= n; i++)
	{
		cout << i << "\t" << torony(i) << endl;
	}
	*/
	cout << torony(n) << endl;
}

int torony(int n) {
	int asd = 20210108;
	vector<unsigned long long> sorozat(n + 1);
	if (n == 1)
		return 2;
	else if(n == 2)
		return 4;
	else if(n == 3)
		return 10;
	else {
		sorozat[1] = 2;
		sorozat[2] = 4;
		sorozat[3] = 10;
		for (int i = 4; i < n + 1; i++)
		{
			sorozat[i] = (2*sorozat[i - 1] + 2*sorozat[i - 3])%asd;
		}
		return sorozat[n];
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1820 KiB
2Accepted0/01ms1880 KiB
3Accepted3/31ms1908 KiB
4Accepted3/31ms1904 KiB
5Accepted4/41ms1900 KiB
6Accepted4/41ms1904 KiB
7Accepted4/416ms17428 KiB
8Accepted4/43ms3656 KiB
9Accepted4/41ms1908 KiB
10Accepted4/41ms1908 KiB
11Accepted4/44ms4820 KiB
12Accepted4/414ms17036 KiB
13Accepted4/413ms15352 KiB
14Accepted4/46ms6900 KiB
15Accepted2/21ms1900 KiB
16Accepted2/21ms1900 KiB