17702022-12-02 21:35:03kdbToronyépítés (80 pont)cpp11Accepted 80/8013ms10588 KiB
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m = 20210108;
    cin >> n;
    vector<int> vec(n + 1);
    vec[0] = 1;
    vec[1] = 3;
    for (size_t i = 2; i < n + 1; i++)
    {
        vec[i] = (vec[i - 1] * 3 + vec[i - 2]) % m;
    }
    cout << vec[n] << endl;
    return 0;
}
/*
5
-360

2021
-6647084
*/
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1824 KiB
2Accepted0/02ms2032 KiB
3Accepted4/42ms2224 KiB
4Accepted4/42ms2428 KiB
5Accepted5/52ms2632 KiB
6Accepted5/52ms2604 KiB
7Accepted6/613ms10180 KiB
8Accepted6/63ms3568 KiB
9Accepted7/72ms2808 KiB
10Accepted7/72ms2932 KiB
11Accepted8/84ms4352 KiB
12Accepted8/812ms10588 KiB
13Accepted8/810ms9948 KiB
14Accepted8/86ms5856 KiB
15Accepted2/22ms3572 KiB
16Accepted2/22ms3580 KiB