6222021-11-04 20:50:33goczbaliToronyépítés (1,1,3,3)cpp14Accepted 50/5016ms9440 KiB
#include <iostream>
#include <vector>

using namespace std;

#define MOD 20210108

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

    vector<int> dp(n + 1);

    dp[0] = 1;

    for (int i = 1; i <= n; i++) {
        dp[i] = (dp[i - 1] * 2) % MOD;

        if (i >= 3) {
            dp[i] += (dp[i - 3] * 2) % MOD;
            dp[i] %= MOD;
        }
    }

    cout << dp[n] << endl;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1740 KiB
2Accepted0/01ms1784 KiB
3Accepted3/31ms1720 KiB
4Accepted3/31ms1724 KiB
5Accepted4/41ms1824 KiB
6Accepted4/41ms1720 KiB
7Accepted4/416ms9440 KiB
8Accepted4/43ms2552 KiB
9Accepted4/41ms1824 KiB
10Accepted4/41ms1720 KiB
11Accepted4/44ms3200 KiB
12Accepted4/416ms9440 KiB
13Accepted4/414ms8404 KiB
14Accepted4/46ms4244 KiB
15Accepted2/21ms1828 KiB
16Accepted2/21ms1724 KiB