38282023-03-03 10:38:43ZsofiaKeresztelyToronyépítés (1,1,3,3)cpp14Accepted 50/5018ms10768 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll MOD = 20210108;

int add(int a, int b){
    return (a + b) % MOD;
}

int main()
{
    int n;
    cin >> n;
    vector<int> dp(max(3, n+1), 0);
    dp[0] = 1;
    dp[1] = 2;
    dp[2] = 4;
    for (int i=3; i<=n; i++){
        dp[i] = add(add(dp[i-1], dp[i-1]), add(dp[i-3], dp[i-3]));
    }
    cout << dp[n];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1684 KiB
2Accepted0/02ms1936 KiB
3Accepted3/32ms2012 KiB
4Accepted3/33ms2252 KiB
5Accepted4/43ms2352 KiB
6Accepted4/42ms2468 KiB
7Accepted4/418ms10332 KiB
8Accepted4/44ms3660 KiB
9Accepted4/42ms2796 KiB
10Accepted4/43ms2920 KiB
11Accepted4/46ms4396 KiB
12Accepted4/417ms10768 KiB
13Accepted4/417ms9804 KiB
14Accepted4/48ms5644 KiB
15Accepted2/22ms3388 KiB
16Accepted2/23ms3596 KiB