4202021-11-03 08:56:50SzankaBenedekToronyépítés (1,1,3,3)cpp11Runtime error 42/5013ms9568 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
base42/50
1Accepted0/02ms1800 KiB
2Accepted0/01ms1844 KiB
3Accepted3/31ms1908 KiB
4Accepted3/31ms1908 KiB
5Runtime error0/42ms1908 KiB
6Runtime error0/41ms1908 KiB
7Accepted4/412ms9540 KiB
8Accepted4/43ms2664 KiB
9Accepted4/41ms1936 KiB
10Accepted4/41ms1944 KiB
11Accepted4/43ms3320 KiB
12Accepted4/413ms9568 KiB
13Accepted4/410ms8536 KiB
14Accepted4/44ms4372 KiB
15Accepted2/21ms1964 KiB
16Accepted2/21ms1964 KiB