QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207972 | #6566. Power of Divisors | Thallium54# | WA | 0ms | 3804kb | C++20 | 1.3kb | 2023-10-09 01:46:57 | 2023-10-09 01:46:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll x;
cin >> x;
auto is_prime = [&](int x) {
for (int f = 2; f * f <= x; f++) {
if (x % f == 0) return false;
}
return true;
};
ll sq = sqrt(x);
while (sq * sq > x) sq--;
while ((sq + 1) * (sq + 1) <= x) sq++;
if (sq * sq == x && is_prime(sq)) {
cout << sq << endl;
return 0;
}
const int N = 1e3;
for (int i = 1; i <= N; i++) {
if (is_prime(i)) {
ll pp = i * i;
if (pp * pp * pp == x) {
cout << pp << endl;
return 0;
}
}
int cnt = 0;
for (int f = 1; f * f <= i; f++) {
if (i % f == 0) {
cnt++;
if (i / f != f) {
cnt++;
}
}
}
__int128 pw = 1;
for (int j = 0; j < cnt; j++) {
pw *= i;
if (pw > 1e18) {
break;
}
}
if (pw == x) {
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1000000000000000000
output:
100
result:
ok single line: '100'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10372926089038969
output:
218089
result:
ok single line: '218089'
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
10642944803293201
output:
-1
result:
wrong answer 1st lines differ - expected: '10157', found: '-1'