4832021-11-03 18:04:25SzankaBenedekToronyépítés (1,1,3,3)cpp11Accepted 50/506ms1988 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int i;
    cin >> i;

    int t[3];
    t[0] = 2;
    t[1] = 4;
    t[2] = 10;
    for (; i > 3; i -= 3)
    {
        t[0] = 2 * (t[2] + t[0]) % 20210108;
        t[1] = 2 * (t[0] + t[1]) % 20210108;
        t[2] = 2 * (t[1] + t[2]) % 20210108;
    }
    cout << t[i - 1] << "\n";
}

// int t[3];
// t[0] = 2;
// t[1] = 4;
// t[2] = 10;
// for (; i > 3; i -= 3)
// {
//     t[0] = (2 * t[2] + 2 * t[0]) % 20210108;
//     t[1] = (2 * t[0] + 2 * t[1]) % 20210108;
//     t[2] = (2 * t[1] + 2 * t[2]) % 20210108;
// }
// cout << t[i - 1] << "\n";

// int v[input];
// v[0] = 2;
// v[1] = 4;
// v[2] = 10; //8+2
// for (int n = 3; n < input; n++)
// {
//     v[n] = (2 * v[n - 1] + 2 * v[n - 3]) % 20210108;
// }
// cout << v[input - 1] << "\n";
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1896 KiB
2Accepted0/01ms1912 KiB
3Accepted3/31ms1976 KiB
4Accepted3/31ms1972 KiB
5Accepted4/41ms1976 KiB
6Accepted4/41ms1968 KiB
7Accepted4/46ms1988 KiB
8Accepted4/42ms1968 KiB
9Accepted4/41ms1972 KiB
10Accepted4/41ms1968 KiB
11Accepted4/42ms1968 KiB
12Accepted4/46ms1980 KiB
13Accepted4/44ms1972 KiB
14Accepted4/43ms1972 KiB
15Accepted2/21ms1980 KiB
16Accepted2/21ms1968 KiB