3172021-10-06 22:00:34fr4ncadToronyépítés (1,1,3,3)cpp11Runtime error 45/5014ms17436 KiB
// torony.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>;
using namespace std;

long fibonacci(int);

int main()
{
    int n;
    cin >> n;
    cout << fibonacci(n);

}

long fibonacci(int n)
{
    if (n > 0)
    {
        vector<long> lista(n + 1);
        lista[0] = 0;
        lista[1] = 2;
        lista[2] = 4;
        lista[3] = 10;
        for (size_t i = 4; i < n + 1; i++)
        {
            lista[i] = (2*(lista[i - 3] + lista[i - 1])) % 20210108;
        }
        return lista[n];
    }
    else
    {
        return 0;
    }
}
// lefed(n) = lefed(n-1) +lefed(n-1) + lefed(n-3) + lefed(n-3)
SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/02ms1800 KiB
2Accepted0/01ms1908 KiB
3Accepted3/31ms1904 KiB
4Runtime error0/31ms1916 KiB
5Accepted4/41ms1916 KiB
6Accepted4/41ms1920 KiB
7Accepted4/414ms17436 KiB
8Accepted4/43ms3688 KiB
9Accepted4/41ms1928 KiB
10Accepted4/41ms1936 KiB
11Accepted4/44ms4880 KiB
12Accepted4/414ms17068 KiB
13Accepted4/414ms15456 KiB
14Accepted4/46ms6964 KiB
15Accepted2/21ms1956 KiB
16Runtime error0/21ms1956 KiB