QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#143076 | #6566. Power of Divisors | UrgantTeam# | TL | 2ms | 3636kb | C++23 | 1.0kb | 2023-08-20 15:26:30 | 2023-08-20 15:26:47 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long double ld;
typedef long long ll;
const int MAX_BOUND = (int) 1e6;
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
ll x;
cin >> x;
if (x == 1) cout << "1\n", exit(0);
for (int i = 2; i <= MAX_BOUND; i++)
{
ll cur = i;
int step = 1;
while (cur < x) cur *= i, step++;
if (cur != x) continue;
int divis = 0;
for (int j = 1; j * j <= i; j++)
{
if (i % j != 0) continue;
divis++;
if (j != i / j) divis++;
}
if (divis == step) cout << i << '\n', exit(0);
}
ll sq = sqrtl(x);
while (sq * sq > x) sq--;
while ((sq + 1) * (sq + 1) <= x) sq++;
bool is_prime = true;
for (int i = 2; i * i <= sq; i++)
if (sq % i == 0) is_prime = false;
if (sq * sq == x && is_prime) cout << sq << '\n', exit(0);
cout << "-1\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3424kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3372kb
input:
1000000000000000000
output:
100
result:
ok single line: '100'
Test #9:
score: -100
Time Limit Exceeded
input:
10372926089038969