QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#150637#6566. Power of DivisorsrgnerdplayerWA 2ms3500kbC++201.5kb2023-08-25 22:44:072023-08-25 22:44:08

Judging History

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

  • [2023-08-25 22:44:08]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3500kb
  • [2023-08-25 22:44:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    
    auto solve = [&]() {
        i64 n;
        cin >> n;

        i64 ans = n + 1;

        for (int p = 2; p <= 60; p++) {
            i64 low = 2, high = n;
            while (low < high) {
                i64 mid = low + high >> 1;
                i64 x = 1;
                for (int i = 0; i < p; i++) {
                    if (x > n / mid) {
                        x = n + 1;
                    } else {
                        x *= mid;
                    }
                }
                if (x >= n) {
                    high = mid;
                } else {
                    low = mid + 1;
                }
            }
            i64 x = 1;
            for (int i = 0; i < p; i++) {
                if (x > n / low) {
                    x = n + 1;
                } else {
                    x *= low;
                }
            }
            if (x != n) {
                continue;
            }
            int divs = 0;
            for (int i = 1; i * i <= low; i++) {
                if (low % i == 0) {
                    divs++;
                    if (i * i != low) {
                        divs++;
                    }
                }
            }
            if (divs == p) {
                ans = min(ans, low);
            }
        }

        cout << (ans == n + 1 ? -1 : ans) << '\n';
    };

    solve();

    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3420kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3396kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

-1

result:

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