3692021-11-02 10:12:42kovacs.peter.18fToronyépítés (1,1,3,3)cpp11Runtime error 38/5061ms61648 KiB
#include <iostream>
#include <vector>

using namespace std;

vector<int> variationS;

int variations(int n) {
    if (n < 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    if (variationS[n] != -1) {
        return variationS[n];
    }
    return variationS[n] = (2 * variations(n - 1) + 2 * variations(n - 3)) % 20210108;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    variationS.resize(N + 1, -1);
    cout << variations(N) << '\n';
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/02ms1824 KiB
2Accepted0/02ms2104 KiB
3Accepted3/32ms1972 KiB
4Accepted3/31ms1964 KiB
5Accepted4/41ms1972 KiB
6Accepted4/41ms1968 KiB
7Runtime error0/461ms61628 KiB
8Accepted4/48ms10636 KiB
9Accepted4/41ms2000 KiB
10Accepted4/41ms2012 KiB
11Accepted4/410ms15976 KiB
12Runtime error0/434ms61644 KiB
13Runtime error0/428ms61648 KiB
14Accepted4/417ms25500 KiB
15Accepted2/21ms2024 KiB
16Accepted2/21ms2020 KiB