3192021-10-06 22:07:20fr4ncadToronyépítés (1,1,3,3)cpp11Accepted 50/5012ms9504 KiB
// torony.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

int fibonacci(int);

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

}

int fibonacci(int n)
{
    if (n > 0)
    {
        vector<int> 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;
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1812 KiB
2Accepted0/01ms1836 KiB
3Accepted3/31ms1888 KiB
4Accepted3/31ms1892 KiB
5Accepted4/41ms1888 KiB
6Accepted4/41ms1784 KiB
7Accepted4/412ms9504 KiB
8Accepted4/42ms2616 KiB
9Accepted4/41ms1784 KiB
10Accepted4/41ms1888 KiB
11Accepted4/43ms3264 KiB
12Accepted4/410ms9504 KiB
13Accepted4/49ms8460 KiB
14Accepted4/44ms4304 KiB
15Accepted2/21ms1892 KiB
16Accepted2/21ms1888 KiB