842021-01-10 16:07:12lacitoToronyépítés (1,1,3,3)cpp11Accepted 50/5012ms17576 KiB
#include <iostream>
using namespace std;

long long lehetoseg[1000001];

int main() {
  int n, p = 1, z = 1, s = 3, f = 3;
  cin >> n;
  lehetoseg[0] = 2;
  lehetoseg[1] = 4;
  lehetoseg[2] = 10;
  for (int i = 3; i < n; i++){
    lehetoseg[i] = (lehetoseg[i - 1] * 2 + lehetoseg[i - 3] * 2) % 20210108;
  }
  cout << lehetoseg[n - 1] << endl;
	return 0;
}

/*
n   f(n)
1   2
2   4
3   10
4   24
5   56

f[n] = 2 * f[n-1] + 2 * f[n - 3]

F/S - P/Z -> 2*f(n-1)   F/S -> 2*f(n-3)
F/S
F/S
X
X

*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms1876 KiB
2Accepted0/01ms1908 KiB
3Accepted3/31ms1952 KiB
4Accepted3/31ms1952 KiB
5Accepted4/41ms1960 KiB
6Accepted4/41ms1956 KiB
7Accepted4/412ms17576 KiB
8Accepted4/42ms3816 KiB
9Accepted4/41ms1956 KiB
10Accepted4/41ms1960 KiB
11Accepted4/43ms5076 KiB
12Accepted4/412ms17304 KiB
13Accepted4/49ms15580 KiB
14Accepted4/44ms7148 KiB
15Accepted2/21ms1952 KiB
16Accepted2/21ms1952 KiB