50382023-04-10 21:15:40TSomaToronyépítés (1,1,3,3)cpp14Accepted 50/504ms3228 KiB
#undef _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <stdio.h>
#include <stdint.h>

int main()
{
    int N;
#pragma warning(suppress : 4996)
    scanf("%d\n", &N);    

    if (N > 0) {
        int_fast32_t a = 2, b = 4, c = 10, d = 24, e = 56, f = 132;
        const int_fast32_t x = 2, y = 10105054000000000, z = 202101080000, m = 20210108;

        N -= 6;

        while (N > 0)
        {
            a = x * (f + d);
            b = x * (a + e);
            c = x * (b + f);
            d = x * (c + a);
            e = x * (d + b);
            f = x * (e + c);

            if (f >= y) {
                d %= z;
                e %= z;
                f %= z;
            }

            N -= 6;
        }


        switch (N % 6) {
        case 0: printf("%d\n", f % m); break;
        case -1: printf("%d\n", e % m); break;
        case -2: printf("%d\n", d % m); break;
        case -3: printf("%d\n", c % m); break;
        case -4: printf("%d\n", b % m); break;
        case -5: printf("%d\n", a % m); break;
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1332 KiB
2Accepted0/02ms1496 KiB
3Accepted3/33ms1668 KiB
4Accepted3/32ms1964 KiB
5Accepted4/42ms1904 KiB
6Accepted4/42ms2144 KiB
7Accepted4/44ms2268 KiB
8Accepted4/43ms2380 KiB
9Accepted4/43ms2712 KiB
10Accepted4/42ms2600 KiB
11Accepted4/43ms2828 KiB
12Accepted4/44ms2884 KiB
13Accepted4/44ms2984 KiB
14Accepted4/43ms3000 KiB
15Accepted2/22ms3044 KiB
16Accepted2/23ms3228 KiB