50392023-04-10 21:18:02TSomaToronyépítés (1,1,3,3)cpp14Accepted 50/504ms3304 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/03ms1376 KiB
2Accepted0/02ms1508 KiB
3Accepted3/33ms1820 KiB
4Accepted3/33ms2028 KiB
5Accepted4/43ms2276 KiB
6Accepted4/42ms2128 KiB
7Accepted4/44ms2492 KiB
8Accepted4/43ms2592 KiB
9Accepted4/42ms2792 KiB
10Accepted4/42ms2948 KiB
11Accepted4/43ms2792 KiB
12Accepted4/44ms2760 KiB
13Accepted4/44ms3012 KiB
14Accepted4/43ms3056 KiB
15Accepted2/22ms3304 KiB
16Accepted2/22ms3280 KiB