QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#359658 | #6566. Power of Divisors | LaStataleBlue# | WA | 1ms | 3688kb | C++23 | 1.7kb | 2024-03-20 19:47:41 | 2024-03-20 19:47:42 |
Judging History
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'