QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227568 | #6566. Power of Divisors | Nerovix# | WA | 29ms | 7592kb | C++20 | 1.0kb | 2023-10-27 18:46:40 | 2023-10-27 18:46:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int d[1000100];
ll qpow(ll a, ll b) {
ll res = 1;
while(b) {
if(b & 1) {
if(res > LLONG_MAX / a)
return LLONG_MAX;
res *= a;
}
if(a > LLONG_MAX / a)
return LLONG_MAX;
a *= a, b >>= 1;
}
return res;
}
bool isp(ll x) {
for(ll i = 2; i * i <= x; i++)
if(x % i == 0) return false;
return true;
}
signed main() {
ll x;
cin >> x;
for(int i = 1; i <= 1e6; i++)
for(int j = i; j <= 1e6; j += i)
d[j]++;
for(int i = 1; i <= 1e6; i++) {
// cout << i << ' ' << d[i] << '\n';
if(qpow(i, d[i]) == x) {
cout << i << '\n';
return 0;
}
}
// cout << 'f';
ll p = sqrt(x);
for(ll i = p - 10; i <= p + 10; i++) {
if(i * i == x && isp(i)) {
cout << i << '\n';
return 0;
}
}
cout << "-1\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 19ms
memory: 7436kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 22ms
memory: 7532kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 29ms
memory: 7504kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 18ms
memory: 7588kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 26ms
memory: 7500kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 25ms
memory: 7592kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 23ms
memory: 7504kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: -100
Wrong Answer
time: 28ms
memory: 7504kb
input:
1000000000000000000
output:
-1
result:
wrong answer 1st lines differ - expected: '100', found: '-1'