3792021-11-03 08:17:18JaksicsPéterToronyépítés (1,1,3,3)cpp11Accepted 50/5014ms17432 KiB
#include <iostream>
#include <vector>

using namespace std;

int torony(int);

int main()
{
	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/02ms1804 KiB
2Accepted0/01ms1844 KiB
3Accepted3/31ms1888 KiB
4Accepted3/31ms1888 KiB
5Accepted4/41ms1784 KiB
6Accepted4/41ms1892 KiB
7Accepted4/413ms17432 KiB
8Accepted4/43ms3652 KiB
9Accepted4/41ms1784 KiB
10Accepted4/41ms1888 KiB
11Accepted4/44ms4824 KiB
12Accepted4/414ms17036 KiB
13Accepted4/412ms15348 KiB
14Accepted4/44ms6900 KiB
15Accepted2/21ms1788 KiB
16Accepted2/21ms1888 KiB