Submission #47225493


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/modint>

namespace {
using ModInt [[maybe_unused]] = atcoder::modint998244353;
using Num [[maybe_unused]] = long long int;
using Vec [[maybe_unused]] = std::vector<Num>;
using Set [[maybe_unused]] = std::set<Num>;
using Mset [[maybe_unused]] = std::multiset<Num>;
using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

template<typename T>
using Q [[maybe_unused]] = std::queue<T>;

template<typename T>
using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

void solve(std::istream& is, std::ostream& os) {
    Num nb {0};
    is >> nb;

    if (nb == 1) {
        os << "1\n";
        return;
    }

    const __int128 bb = nb;
    __int128 a {2};

    for(;;) {
        __int128 c {1};
        for(Num i{0}; i<a; ++i) {
            c *= a;
        }

        if (c == bb) {
            os << static_cast<Num>(a) << "\n";
            return;
        }

        if (c > bb) {
            break;
        }

        ++a;
    }

    os << "-1\n";
    return;
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task B - A^A
User zettsut
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1165 Byte
Status AC
Exec Time 1 ms
Memory 3604 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 21
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_hack_1_00.txt, 02_hack_1_01.txt, 03_hack_2_00.txt, 03_hack_2_01.txt, 03_hack_2_02.txt, 03_hack_2_03.txt, 04_corner_00.txt, 04_corner_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3568 KiB
00_sample_01.txt AC 1 ms 3456 KiB
00_sample_02.txt AC 1 ms 3464 KiB
01_random_00.txt AC 1 ms 3500 KiB
01_random_01.txt AC 1 ms 3472 KiB
01_random_02.txt AC 1 ms 3604 KiB
01_random_03.txt AC 1 ms 3600 KiB
01_random_04.txt AC 1 ms 3460 KiB
01_random_05.txt AC 1 ms 3516 KiB
01_random_06.txt AC 1 ms 3388 KiB
01_random_07.txt AC 1 ms 3572 KiB
01_random_08.txt AC 1 ms 3448 KiB
01_random_09.txt AC 1 ms 3572 KiB
02_hack_1_00.txt AC 1 ms 3476 KiB
02_hack_1_01.txt AC 1 ms 3508 KiB
03_hack_2_00.txt AC 1 ms 3564 KiB
03_hack_2_01.txt AC 1 ms 3456 KiB
03_hack_2_02.txt AC 1 ms 3440 KiB
03_hack_2_03.txt AC 1 ms 3468 KiB
04_corner_00.txt AC 1 ms 3444 KiB
04_corner_01.txt AC 1 ms 3504 KiB