3182021-10-06 22:03:34fr4ncadToronyépítés (1,1,3,3)cpp14Runtime error 45/5014ms17472 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/01ms1876 KiB
3Accepted3/31ms1908 KiB
4Runtime error0/31ms1904 KiB
5Accepted4/41ms1912 KiB
6Accepted4/41ms1928 KiB
7Accepted4/414ms17472 KiB
8Accepted4/43ms3704 KiB
9Accepted4/41ms1940 KiB
10Accepted4/41ms1940 KiB
11Accepted4/44ms4884 KiB
12Accepted4/414ms17100 KiB
13Accepted4/413ms15416 KiB
14Accepted4/46ms6980 KiB
15Accepted2/21ms1964 KiB
16Runtime error0/22ms1956 KiB