17942022-12-03 17:48:45kdbToronyépítés (2,2,3,3)cpp11Accepted 40/404ms5140 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    const int m = 20210108;
    vector<int> vec(n+1);
    vec[0] = 1;
    vec[1] = 0;
    vec[2] = 2;
    vec[3] = 2;
    vec[4] = 4;
    vec[5] = 8;

    for (size_t i = 6; i < n + 1; i++)
    {
        vec[i] = (2 * vec[i - 2] + 2 * vec[i - 3]) % m;
    }
    cout << vec[n] << endl;

    return 0;
}
/*
5
-8

2021
-4616008
*/
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1972 KiB
2Accepted0/02ms2216 KiB
3Accepted2/22ms2264 KiB
4Accepted2/22ms2472 KiB
5Accepted3/32ms2672 KiB
6Accepted3/32ms2884 KiB
7Accepted3/34ms4356 KiB
8Accepted3/33ms3832 KiB
9Accepted3/32ms3144 KiB
10Accepted3/32ms3376 KiB
11Accepted3/33ms4796 KiB
12Accepted3/34ms4892 KiB
13Accepted4/43ms5140 KiB
14Accepted4/43ms4696 KiB
15Accepted2/22ms4000 KiB
16Accepted2/22ms4164 KiB