4262021-11-03 09:04:13SzankaBenedekToronyépítés (1,1,3,3)cpp11Runtime error 42/5013ms9516 KiB
#include <iostream>
#include <vector>

using namespace std;

int f(int input)
{
    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/02ms1808 KiB
2Accepted0/01ms1828 KiB
3Accepted3/31ms1784 KiB
4Accepted3/31ms1784 KiB
5Runtime error0/41ms1880 KiB
6Runtime error0/41ms2004 KiB
7Accepted4/413ms9516 KiB
8Accepted4/43ms2624 KiB
9Accepted4/41ms1796 KiB
10Accepted4/41ms1796 KiB
11Accepted4/43ms3276 KiB
12Accepted4/410ms9516 KiB
13Accepted4/49ms8472 KiB
14Accepted4/44ms4316 KiB
15Accepted2/21ms1900 KiB
16Accepted2/21ms1796 KiB