QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709164 | #6566. Power of Divisors | tassei903 | RE | 14ms | 10600kb | Python3 | 1.2kb | 2024-11-04 12:29:15 | 2024-11-04 12:29:15 |
Judging History
answer
from math import floor
def f(n, e):
if e <= 4:
ok = 0
ng = 10 ** 18
while ng - ok > 1:
mid = ok + ng >> 1
if mid ** e <= n:
ok = mid
else:
ng = mid
if ok ** e == n:
return ok
else:
for x in range(1, 10 ** 18):
if x ** e > n:
return -1
if x ** e == n:
return x
def divisors(n):
a = []
i = 1
while i * i <= n:
if n % i == 0:
a.append(i)
if n // i != i:
a.append(n//i)
i += 1
return a
def solve():
n = int(input())
if n == 1:
print(1)
return
b, e = n, 1
for i in range(63, 1, -1):
x = f(n, i)
if x == -1:
continue
b, e = x, i
break
if e == 1:
print(-1)
return
ans = 10 ** 20
for j in sorted(divisors(e))[:-1]:
x = b ** j
if len(divisors(x)) == e // j:
print(x)
break
else:
print(-1)
solve()
# for _ in range(int(input())):
# solve()
详细
Test #1:
score: 100
Accepted
time: 11ms
memory: 10580kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 5ms
memory: 10484kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 14ms
memory: 10600kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 14ms
memory: 10592kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: -100
Dangerous Syscalls
input:
10