4182021-11-03 08:55:58TSomaToronyépítés (1,1,3,3)cpp11Accepted 50/508ms1908 KiB
#include <iostream>
#include <vector>

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

    int N;
    std::cin >> N;

    //std::vector<int> v(N+1);
    int v[4];

    v[0] = 1;
    v[1] = 2;
    v[2] = 4;
    v[3] = 0;

    int a, b, c;

    for (size_t i = 3; i < N + 1; i++)
    {
        c = i % 4;
        a = c - 1;
        b = c - 3;

        if (a < 0)
            a = 3;
        if (b < 0)
            b += 4;

        v[c] = (2 * v[a] + 2 * v[b]);
        if (v[c] > 20210108) {
            v[c] %= 20210108;
        }
    }

    std::cout << v[N%4];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1816 KiB
2Accepted0/01ms1848 KiB
3Accepted3/31ms1900 KiB
4Accepted3/31ms1900 KiB
5Accepted4/41ms1908 KiB
6Accepted4/41ms1908 KiB
7Accepted4/48ms1900 KiB
8Accepted4/42ms1908 KiB
9Accepted4/41ms1900 KiB
10Accepted4/41ms1904 KiB
11Accepted4/43ms1904 KiB
12Accepted4/48ms1900 KiB
13Accepted4/48ms1900 KiB
14Accepted4/44ms1904 KiB
15Accepted2/21ms1904 KiB
16Accepted2/21ms1904 KiB