15212022-11-21 23:59:08TomaSajtToronyépítés (1,1,3,3)cpp14Accepted 50/5010ms10936 KiB
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0)
using namespace std;

int main() {
    speed;
    int n; cin >> n;
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (i >= 1) dp[i] += 2 * dp[i - 1];
        if (i >= 3) dp[i] += 2 * dp[i - 3];
        dp[i] %= 20210108;
    }
    cout << dp[n];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2104 KiB
2Accepted0/02ms2116 KiB
3Accepted3/32ms2312 KiB
4Accepted3/32ms2532 KiB
5Accepted4/42ms2740 KiB
6Accepted4/42ms2808 KiB
7Accepted4/410ms10724 KiB
8Accepted4/43ms3908 KiB
9Accepted4/42ms3092 KiB
10Accepted4/42ms3092 KiB
11Accepted4/44ms4432 KiB
12Accepted4/49ms10936 KiB
13Accepted4/49ms10200 KiB
14Accepted4/44ms5864 KiB
15Accepted2/22ms3484 KiB
16Accepted2/22ms3624 KiB