QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#348871 | #6566. Power of Divisors | realcomplex0# | WA | 317ms | 7568kb | C++17 | 1.2kb | 2024-03-09 22:01:00 | 2024-03-09 22:01:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
bool is_pr(ll p){
for(ll x = 2; x * 1ll * x <= p; x ++ ){
if(p % x == 0) return false;
}
return true;
}
const int N = (int)1e6 + 10;
int cnt[N];
ll chk;
int main(){
ll x;
cin >> x;
if(x==1){
cout << "1\n";
return 0;
}
ll l = 1;
ll r = (ll)2e9;
ll mid;
while(l < r){
mid = (l + r) / 2;
if(mid * 1ll * mid >= x) r = mid;
else l = mid + 1;
}
ll low = (ll)2e9;
if(l * 1ll * l == x && is_pr(x)){
low = l;
}
for(int i = 1; i < N; i ++ ){
for(int j = i; j < N; j += i) cnt[j]++;
if(i != 1){
chk=0;
ll y = x;
while(y%i==0){
chk++;
y/=i;
}
if(y==1 && chk == cnt[i]){
low=min(low, (ll)i);
}
}
}
if(low > (ll)1e9){
cout << "-1\n";
}
else{
cout << low << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 21ms
memory: 7416kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 24ms
memory: 7488kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 20ms
memory: 7500kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 21ms
memory: 7532kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 25ms
memory: 7380kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 24ms
memory: 7568kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 21ms
memory: 7496kb
input:
1000000000000000000
output:
100
result:
ok single line: '100'
Test #9:
score: 0
Accepted
time: 20ms
memory: 7480kb
input:
10372926089038969
output:
218089
result:
ok single line: '218089'
Test #10:
score: 0
Accepted
time: 20ms
memory: 7420kb
input:
10642944803293201
output:
10157
result:
ok single line: '10157'
Test #11:
score: -100
Wrong Answer
time: 317ms
memory: 7488kb
input:
10646534823110209
output:
-1
result:
wrong answer 1st lines differ - expected: '103182047', found: '-1'