Submission #29303529


Source Code Expand

/**
 * Paliukh 02.07.2022
 */
#ifdef ONPC
#define _GLIBCXX_DEBUG
#else
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int mod = 998244353;

vector<int> calced(1e6, 0);

void Precalc() {
    calced[0] = 0;
    calced[1] = 1;
    calced[2] = 2;
    calced[3] = 3;
    for (int i = 4; i < 1e6; ++i) {
        int left = i / 2;
        int right = i - left;
        calced[i] = (1LL * calced[left] * calced[right]) % mod;
//        cout << calced[i];
    }
}

ll Calc(ll val) {
    if (val < calced.size()) {
        return calced[val];
    }
    if (val % 2 == 0) {
        ll res = Calc(val / 2);
        return (1LL * res * res) % mod;
    }
    return (1LL * Calc(val / 2) * Calc((val + 1) / 2)) % mod;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef ONPC
    freopen("input.txt", "r", stdin);
    //  freopen("output.tvalst", "w", stdout);
#endif
    ll val;
    cin >> val;
    Precalc();
    cout << Calc(val);
    return 0;
}

Submission Info

Submission Time
Task A - Floor, Ceil - Decomposition
User Paliukh
Language C++ (GCC 9.2.1)
Score 300
Code Size 1144 Byte
Status AC
Exec Time 145 ms
Memory 7060 KiB

Compile Error

./Main.cpp: In function ‘ll Calc(ll)’:
./Main.cpp:36:13: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   36 |     if (val < calced.size()) {
      |         ~~~~^~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 22
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 11 ms 6840 KiB
01_sample_02.txt AC 9 ms 7060 KiB
01_sample_03.txt AC 9 ms 6972 KiB
02_small_01.txt AC 12 ms 7000 KiB
02_small_02.txt AC 10 ms 6860 KiB
02_small_03.txt AC 10 ms 6996 KiB
02_small_04.txt AC 18 ms 6880 KiB
02_small_05.txt AC 9 ms 6840 KiB
02_small_06.txt AC 11 ms 6864 KiB
02_small_07.txt AC 13 ms 6856 KiB
02_small_08.txt AC 11 ms 6856 KiB
02_small_09.txt AC 10 ms 6972 KiB
02_small_10.txt AC 9 ms 6860 KiB
03_rand_01.txt AC 145 ms 6864 KiB
03_rand_02.txt AC 30 ms 7024 KiB
03_rand_03.txt AC 63 ms 6844 KiB
03_rand_04.txt AC 99 ms 6768 KiB
03_rand_05.txt AC 20 ms 6992 KiB
04_handmade_01.txt AC 11 ms 6808 KiB
04_handmade_02.txt AC 12 ms 6884 KiB
04_handmade_03.txt AC 11 ms 6996 KiB
04_handmade_04.txt AC 8 ms 6996 KiB