4902021-11-03 18:15:54SzankaBenedekToronyépítés (1,1,3,3)cpp11Accepted 50/507ms1972 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]);
        t[0] = t[0] >= 20210108 ? t[0] % 20210108 : t[0];
        t[1] = 2 * (t[0] + t[1]);
        t[1] = t[1] >= 20210108 ? t[1] % 20210108 : t[1];
        t[2] = 2 * (t[1] + t[2]);
        t[2] = t[2] >= 20210108 ? t[2] % 20210108 : t[2];
    }
    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/02ms1880 KiB
2Accepted0/01ms1936 KiB
3Accepted3/31ms1968 KiB
4Accepted3/31ms1972 KiB
5Accepted4/41ms1968 KiB
6Accepted4/41ms1968 KiB
7Accepted4/47ms1972 KiB
8Accepted4/42ms1968 KiB
9Accepted4/41ms1968 KiB
10Accepted4/41ms1968 KiB
11Accepted4/42ms1968 KiB
12Accepted4/46ms1968 KiB
13Accepted4/46ms1968 KiB
14Accepted4/43ms1968 KiB
15Accepted2/21ms1964 KiB
16Accepted2/21ms1964 KiB