56002023-08-02 13:32:53TomaSajtToronyépítés (80 pont)cpp17Accepted 80/8014ms19044 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 20210108;

int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1);
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i] = 3 * dp[i - 1];
    if (i >= 2) dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }
  cout << dp[n];
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1844 KiB
2Accepted0/03ms2108 KiB
3Accepted4/43ms2312 KiB
4Accepted4/43ms2484 KiB
5Accepted5/53ms2704 KiB
6Accepted5/53ms3036 KiB
7Accepted6/614ms18500 KiB
8Accepted6/64ms4812 KiB
9Accepted7/73ms3112 KiB
10Accepted7/73ms3336 KiB
11Accepted8/84ms6616 KiB
12Accepted8/813ms19044 KiB
13Accepted8/813ms17512 KiB
14Accepted8/87ms9168 KiB
15Accepted2/23ms4192 KiB
16Accepted2/23ms4308 KiB