3982021-11-03 08:30:02ZelenakAndrasToronyépítés (1,1,3,3)cpp11Accepted 50/5012ms9500 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 oszto = 20210108;
    if (n == 0) {
        return ((0)) % oszto;
    } else if (n < 3) {
        return (2 * n) % oszto;
    } else if (n == 3) {
        return (10) % oszto;
    } else {
        vector<int> viktorAVektor(n, 0);
        viktorAVektor[0] = 2 % oszto;
        viktorAVektor[1] = 4 % oszto;
        viktorAVektor[2] = 10 % oszto;
        for (int i = 3; i < n; i++) {
            viktorAVektor[i] = (2 * viktorAVektor[i - 1] + 2 * viktorAVektor[i - 3]) % oszto;
        }
        return viktorAVektor[n - 1];
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1804 KiB
2Accepted0/01ms1832 KiB
3Accepted3/31ms1784 KiB
4Accepted3/31ms1888 KiB
5Accepted4/41ms1784 KiB
6Accepted4/41ms1784 KiB
7Accepted4/410ms9500 KiB
8Accepted4/42ms2616 KiB
9Accepted4/41ms1888 KiB
10Accepted4/41ms1888 KiB
11Accepted4/43ms3260 KiB
12Accepted4/412ms9484 KiB
13Accepted4/49ms8464 KiB
14Accepted4/44ms4304 KiB
15Accepted2/21ms1784 KiB
16Accepted2/21ms1892 KiB