3942021-11-03 08:28:22TSomaToronyépítés (1,1,3,3)cpp11Accepted 50/5013ms9524 KiB
#include <iostream>
#include <vector>

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

    int N;
    std::cin >> N;

    if (N < 1000) {
        int a[1000];

        a[0] = 1;

        for (size_t i = 1; i < N + 1; i++)
        {
            if (i > 2)
            {
                a[i] = (2 * a[i - 1] + 2 * a[i - 3]);
                if (a[i] > 20210108) {
                    a[i] %= 20210108;
                }
            }
            else
                a[i] = i * 2;
        }
        std::cout << a[N];
    }
    else
    {
        std::vector<int> v(N + 1);
        v[0] = 1;

        for (size_t i = 1; i < N + 1; i++)
        {
            if (i > 2)
            {
                v[i] = (2 * v[i - 1] + 2 * v[i - 3]);
                if (v[i] > 20210108) {
                    v[i] %= 20210108;
                }
            }
            else
                v[i] = i * 2;
        }
        std::cout << v[N];
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1756 KiB
2Accepted0/01ms1888 KiB
3Accepted3/31ms1872 KiB
4Accepted3/31ms1892 KiB
5Accepted4/41ms1868 KiB
6Accepted4/41ms1900 KiB
7Accepted4/413ms9524 KiB
8Accepted4/43ms2612 KiB
9Accepted4/41ms1904 KiB
10Accepted4/41ms1912 KiB
11Accepted4/44ms3280 KiB
12Accepted4/412ms9448 KiB
13Accepted4/410ms8476 KiB
14Accepted4/46ms4328 KiB
15Accepted2/21ms1920 KiB
16Accepted2/21ms1924 KiB