832021-01-10 16:03:43lacitoToronyépítés (1,1,3,3)cpp11Wrong answer 43/5014ms17452 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;
    if (i == n - 1){
      cout << lehetoseg[i] << 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
base43/50
1Accepted0/02ms1868 KiB
2Accepted0/01ms1928 KiB
3Accepted3/31ms1900 KiB
4Wrong answer0/31ms1904 KiB
5Accepted4/41ms1904 KiB
6Accepted4/41ms1912 KiB
7Accepted4/414ms17452 KiB
8Accepted4/43ms3780 KiB
9Accepted4/41ms1920 KiB
10Accepted4/41ms1924 KiB
11Accepted4/44ms5048 KiB
12Accepted4/414ms17292 KiB
13Accepted4/413ms15560 KiB
14Accepted4/46ms7208 KiB
15Wrong answer0/21ms1940 KiB
16Wrong answer0/21ms1948 KiB