QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#642288 | #6566. Power of Divisors | enze114514 | WA | 1ms | 3924kb | C++20 | 1.5kb | 2024-10-15 12:35:40 | 2024-10-15 12:35:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
const ld pi = 3.14159265358979323846;
// const int mod = 998244353;
const ll INF = 1e18;
template<typename T>
T chmax(T a, T b) {
return a > b ? a : b;
}
template<typename T>
T chmin(T a, T b) {
return a > b ? b : a;
}
const int N = (int)2e5 + 1, M = N * 2;
ll qpow(ll a, ll b){
ll res = 1;
while(b > 0){
if(b % 2 == 1){
res = (res * a);
}
a = (a * a);
b /= 2;
}
return res;
}
void solve(){
ll x;
cin >> x;
auto f = [&](ll t) -> ll{
ll qwq = 0;
for(ll i = 1; i * i <= t; i++){
if(t % i == 0){
qwq++;
if(t / i != i){
qwq++;
}
}
}
return qwq;
};
if(x == 1){
cout << 1 << endl;
return;
}
for(int i = (x >= 1e14 ? 3 : 2); i <= 64; i++){
ll t = (ll)pow(x, 1.0 / i);
if(qpow(t + 1, i) == x && f(t + 1) == i){
cout << t + 1 << endl;
return;
}
if(qpow(t, i) == x && f(t) == i){
cout << t << endl;
return;
}
}
cout << -1 << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
1000000000000000000
output:
100
result:
ok single line: '100'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3924kb
input:
10372926089038969
output:
218089
result:
ok single line: '218089'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3924kb
input:
10642944803293201
output:
10157
result:
ok single line: '10157'
Test #11:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
10646534823110209
output:
-1
result:
wrong answer 1st lines differ - expected: '103182047', found: '-1'