QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114084 | #6566. Power of Divisors | UFRJ# | WA | 39ms | 6980kb | C++20 | 1.4kb | 2023-06-20 21:39:11 | 2023-06-20 21:39:13 |
Judging History
answer
#include "bits/stdc++.h"
using lint = int64_t;
using namespace std;
const lint linf = 1e18 + 10;
map<lint,lint> memo;
int countDiv(lint x) {
set<lint> st;
for(lint i = 1; i*i <= x; i++) {
if(x % i == 0) {
st.insert(i);
st.insert(x/i);
}
}
return st.size();
}
lint f(lint x) {
lint ans = 1;
for(int i = 0; i < countDiv(x); i++) {
ans *= x;
}
return ans;
}
const int ms = 1e6 + 10;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
vector<int>num(ms);
for(int i=1;i<ms;i++){
for(int j=i;j<ms;j+=i) num[j]++;
}
lint ans = linf;
lint n;
cin>>n;
for(lint i=1;i<ms;i++){
lint cur = 1;
for(int j=0;j<num[i];j++){
if(linf / i < cur) cur = linf;
else cur = cur * i;
}
if(cur == n) ans = min(ans, i);
}
lint lo = 1, hi = 1e9 + 2;
while(lo <= hi){
lint mid = (lo + hi) / 2;
if(mid * mid <= n) lo = mid + 1;
else hi = mid - 1;
}
if(hi >= ms && hi * hi == n){
int d = 0;
for(lint i=2;i*i<=hi;i++){
if(hi % i == 0){
d++;
}
}
if(!d) ans = min(ans, hi);
}
if(ans == linf) cout<<"-1\n";
else cout<<ans<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 35ms
memory: 6908kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 38ms
memory: 6844kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 35ms
memory: 6960kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 34ms
memory: 6912kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 38ms
memory: 6884kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 34ms
memory: 6908kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 37ms
memory: 6876kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: -100
Wrong Answer
time: 39ms
memory: 6980kb
input:
1000000000000000000
output:
60
result:
wrong answer 1st lines differ - expected: '100', found: '60'