120542024-11-26 13:34:52RRoliJárda-L (40)cpp17Accepted 40/401ms512 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, a[29][3];
	cin >> n;
	a[1][0] = 1; a[1][1] = 0; 
	a[2][0] = 2; a[2][1] = 1; 
	for(int i = 3; i <= n; i++) {
		a[i][0] = a[i-1][0] + a[i-2][0] + 2*a[i-1][1];
		a[i][1] = a[i-2][0] + a[i-1][1];
	}
	cout << a[n][0];
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms320 KiB
2Accepted0/01ms512 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted3/31ms356 KiB
9Accepted3/31ms512 KiB
10Accepted3/31ms324 KiB
11Accepted3/31ms320 KiB
12Accepted3/31ms320 KiB
13Accepted3/31ms320 KiB
14Accepted3/31ms320 KiB
15Accepted3/31ms320 KiB
16Accepted3/31ms320 KiB
17Accepted3/31ms320 KiB