QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359658#6566. Power of DivisorsLaStataleBlue#WA 1ms3688kbC++231.7kb2024-03-20 19:47:412024-03-20 19:47:42

Judging History

你现在查看的是最新测评结果

  • [2024-03-20 19:47:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-03-20 19:47:41]
  • 提交

answer

#pragma ide diagnostic ignored "misc-no-recursion"

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef long double db;

#define TESTCASE 0

static void solve([[maybe_unused]] int tc) {
    long long x;
    cin >> x;

    if (x == 1) {
        cout << "1\n";
        return;
    }

    auto f = [&](long long x) -> long long {
        long long ans = 1;
        for (long long i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                long long tmp = 0;
                while (x % i == 0) {
                    x /= i;
                    tmp++;
                }
                ans *= tmp + 1;
            }
        }
        if (x > 1)ans *= 2;
        return ans;
    };

    auto pot = [&](long long x, int esp) {
        long long res = 1;
        for (int i = 0; i < esp && res != LLONG_MAX; i++) {
            if (LLONG_MAX / res <= x)x = LLONG_MAX;
            else res *= x;
        }
        return res;
    };

    auto check = [&](int esp) {
        long long low = 0, up = x + 1;
        while (up - low > 1) {
            long long mid = (up + low) / 2;

            if (pot(mid, esp) >= x)up = mid;
            else low = mid;
        }

        if (pot(up, esp) == x && f(up) == esp) {
            cout << up << "\n";
            exit(0);
        }
    };

    for (int i = 2; i < 100; i++) {
        check(i);
    }
    cout << "-1\n";
}

int main() {
    ios::sync_with_stdio(false);

    if (const char *f = getenv("REDIRECT_STDOUT"); f) {
        freopen(f, "w", stdout);
    }

    int T = 1;
#if TESTCASE
    cin >> T;
#endif

    for (int t = 1; t <= T; t++) {
        solve(t);
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3664kb

input:

1000000000000000000

output:

-1

result:

wrong answer 1st lines differ - expected: '100', found: '-1'