4822021-11-03 18:02:45TSomaToronyépítés (1,1,3,3)cpp11Accepted 50/504ms2008 KiB
#include <iostream>

int fast_mod(const int input, const int ceil) {
    return input >= ceil ? input % ceil : input;
}

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

    int N;
    std::cin >> N;

    int a = 2;
    int b = 4;
    int c = 10;
    for (int n = 3; n < N; n += 3)
    {
        a = 2 * (c + a);
        b = 2 * (a + b);
        c = 2 * (b + c);

        a = fast_mod(a, 20210108);
        b = fast_mod(b, 20210108);
        c = fast_mod(c, 20210108);
    }

    switch (fast_mod(N, 3))
    {
    case 0:
        std::cout << c;
        break;
    case 1:
        std::cout << a;
        break;
    case 2:
        std::cout << b;
        break;
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1900 KiB
2Accepted0/01ms1952 KiB
3Accepted3/31ms1960 KiB
4Accepted3/31ms1964 KiB
5Accepted4/41ms1968 KiB
6Accepted4/41ms1956 KiB
7Accepted4/44ms1960 KiB
8Accepted4/42ms1948 KiB
9Accepted4/42ms1968 KiB
10Accepted4/41ms1988 KiB
11Accepted4/42ms1984 KiB
12Accepted4/44ms1996 KiB
13Accepted4/44ms1972 KiB
14Accepted4/42ms1996 KiB
15Accepted2/21ms2008 KiB
16Accepted2/21ms1996 KiB