159182025-03-20 11:57:3642Toronyépítés (1,1,3,3)cpp17Accepted 50/501ms532 KiB
#include <iostream>
#include <unordered_map>
using namespace std;

unordered_map<int, int> memo = {
    {0, 1}, {1, 2}, {2, 4}, {3, 10}, {4, 24}, {5, 56}
};
const int MOD = 20210108;

int t(int n) {
    if (memo.find(n) != memo.end()) {
        return memo[n];
    }
    int cur;
    if (n % 2 == 0) {
        cur = (1LL * t(n / 2 - 1) * t(n / 2 + 1) + 2LL * (1LL * t(n / 2 - 3) * t(n / 2) + 1LL * t(n / 2 - 2) * t(n / 2 - 1))) % MOD;
    } else {
        cur = (1LL * t(n / 2) * t(n / 2 + 1) + 2LL * (1LL * t(n / 2 - 2) * t(n / 2) + 1LL * t(n / 2 - 1) * t(n / 2 - 1))) % MOD;
    }
    memo[n] = cur;
    return cur;
}

int main() {
    int n;
    cin >> n;
    cout << t(n) << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted4/41ms316 KiB
6Accepted4/41ms316 KiB
7Accepted4/41ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms532 KiB
10Accepted4/41ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Accepted4/41ms320 KiB
14Accepted4/41ms508 KiB
15Accepted2/21ms400 KiB
16Accepted2/21ms508 KiB