4232021-11-03 08:59:13SzankaBenedekToronyépítés (1,1,3,3)cpp11Accepted 50/5017ms10072 KiB
#include <iostream>
#include <vector>

using namespace std;

int f(int input)
{
    if (input == 0)
        return 1;
    if (input == 1)
        return 2;
    if (input == 2)
        return 4;
    if (input == 3)
        return 10;

    // vector<int> v(input);
    // v[0] = 2;
    // v[1] = 4;
    // v[2] = 10; //8+2
    // for (int n = 3; n <= input; n++)
    // {
    //     v[n] = (2 * v[n - 1] + 2 * v[n - 3]) % 20210108;
    // }
    // return v[input-1];

    vector<int> v;
    v.push_back(2);
    v.push_back(4);
    v.push_back(10);
    for (int n = 3; n <= input; n++)
    {
        v.push_back((2 * v[n - 1] + 2 * v[n - 3]) % 20210108);
    }
    return v[input - 1];
}

int main()
{
    int a;
    cin >> a;
    cout << f(a) << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1740 KiB
2Accepted0/01ms1780 KiB
3Accepted3/31ms1828 KiB
4Accepted3/31ms1824 KiB
5Accepted4/41ms1720 KiB
6Accepted4/41ms1824 KiB
7Accepted4/416ms10068 KiB
8Accepted4/43ms2964 KiB
9Accepted4/41ms1720 KiB
10Accepted4/41ms1824 KiB
11Accepted4/44ms3860 KiB
12Accepted4/417ms10072 KiB
13Accepted4/414ms10064 KiB
14Accepted4/47ms5928 KiB
15Accepted2/21ms1828 KiB
16Accepted2/21ms1824 KiB