3772021-11-03 08:15:41ZelenakAndrasToronyépítés (1,1,3,3)cpp11Accepted 50/5012ms9504 KiB
#include <iostream>
#include <vector>

int torony(int n);

using namespace std;

int main() {
    int n;
    cin >> n;

    cout << torony(n) << endl;
}

int torony(int n) {
    int fasz = 20210108;
    if (n == 0) {
        return ((0)) % fasz;
    } else if (n < 3) {
        return (2 * n) % fasz;
    } else if (n == 3) {
        return (10) % fasz;
    } else {
        vector<int> viktorAVektor(n, 0);
        viktorAVektor[0] = 2 % fasz;
        viktorAVektor[1] = 4 % fasz;
        viktorAVektor[2] = 10 % fasz;
        for (int i = 3; i < n; i++) {
            viktorAVektor[i] = (2 * viktorAVektor[i - 1] + 2 * viktorAVektor[i - 3]) % fasz;
        }
        return viktorAVektor[n - 1];
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1808 KiB
2Accepted0/02ms1836 KiB
3Accepted3/31ms1784 KiB
4Accepted3/31ms1784 KiB
5Accepted4/41ms1888 KiB
6Accepted4/41ms1888 KiB
7Accepted4/410ms9504 KiB
8Accepted4/42ms2616 KiB
9Accepted4/41ms1888 KiB
10Accepted4/41ms1892 KiB
11Accepted4/43ms3260 KiB
12Accepted4/412ms9500 KiB
13Accepted4/49ms8460 KiB
14Accepted4/44ms4308 KiB
15Accepted2/21ms1888 KiB
16Accepted2/21ms1784 KiB