17932022-12-03 17:46:14kdbToronyépítés (2,2,3,3)cpp11Wrong answer 38/403ms4500 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
base38/40
1Accepted0/03ms1828 KiB
2Accepted0/02ms2220 KiB
3Accepted2/22ms2272 KiB
4Accepted2/22ms2460 KiB
5Accepted3/32ms2536 KiB
6Accepted3/32ms2544 KiB
7Accepted3/33ms4140 KiB
8Accepted3/33ms3704 KiB
9Accepted3/32ms2820 KiB
10Accepted3/32ms3092 KiB
11Accepted3/33ms4372 KiB
12Accepted3/33ms4368 KiB
13Accepted4/43ms4500 KiB
14Accepted4/43ms4188 KiB
15Accepted2/22ms3352 KiB
16Wrong answer0/22ms3456 KiB