69972023-12-25 09:57:02MagyarKendeSZLGToronyépítés (1,1,3,3)cpp17Accepted 50/5012ms10692 KiB
#include <iostream>
#include <vector>
using namespace std;
#define speed cin.tie(0); ios::sync_with_stdio(0)
const int MOD = 20210108;

int main() {
    speed;

    int N;
    cin >> N;
    vector<int> dp(N + 1);
    dp[0] = 1;

    for (int i = 1; i <= N; i++) {
        dp[i] = (long)((dp[i - 1] * 2) + (i >= 3 ? dp[i - 3] * 2 : 0)) % MOD;
    }

    cout << dp[N];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/03ms2064 KiB
3Accepted3/33ms2280 KiB
4Accepted3/33ms2480 KiB
5Accepted4/43ms2580 KiB
6Accepted4/43ms2768 KiB
7Accepted4/412ms10328 KiB
8Accepted4/44ms3848 KiB
9Accepted4/43ms3044 KiB
10Accepted4/43ms3068 KiB
11Accepted4/44ms4524 KiB
12Accepted4/412ms10692 KiB
13Accepted4/410ms9904 KiB
14Accepted4/46ms5700 KiB
15Accepted2/23ms3376 KiB
16Accepted2/23ms3464 KiB