17922022-12-03 17:45:38kdbToronyépítés (2,2,3,3)cpp11Wrong answer 0/403ms4224 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    const int m = 20210108;
    cin >> n;
    if (n == 1) cout << 1 << endl; return 0;
    vector<int> vec(n+1);
    vec[0] = 2;
    vec[1] = 2;
    vec[2] = 4;
    for (size_t i = 3; i < n + 1; i++)
    {
        vec[i] = (2 * vec[i - 2] + 2 * vec[i - 3]) % m;
    }
    cout << vec[n - 2] << endl;
    return 0;
}
/*
5
-8

2021
-4616008
*/
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1896 KiB
2Wrong answer0/02ms2080 KiB
3Wrong answer0/22ms2288 KiB
4Wrong answer0/22ms2492 KiB
5Wrong answer0/32ms2696 KiB
6Wrong answer0/32ms2900 KiB
7Wrong answer0/32ms3104 KiB
8Wrong answer0/32ms3312 KiB
9Wrong answer0/32ms3532 KiB
10Wrong answer0/32ms3740 KiB
11Wrong answer0/32ms3944 KiB
12Wrong answer0/32ms4024 KiB
13Wrong answer0/42ms4096 KiB
14Wrong answer0/42ms4092 KiB
15Wrong answer0/22ms4096 KiB
16Wrong answer0/22ms4224 KiB