QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#706907#6566. Power of Divisorstassei903#TL 17ms10716kbPython3856b2024-11-03 13:54:492024-11-03 13:54:49

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 13:54:49]
  • 评测
  • 测评结果:TL
  • 用时:17ms
  • 内存:10716kb
  • [2024-11-03 13:54:49]
  • 提交

answer


def f(n, e):
    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:
        return -1

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

n = int(input())
if n == 1:
    print(1)
    exit()

for i in range(63, 0, -1):
    x = f(n, i)
    if x == -1:
        continue
    b, e = x, i
    break

if e == 1:
    print(-1)
    exit()

ans = 10 ** 20
for j in divisors(e):
    x = b ** j
    if len(divisors(x)) == e // j:
        ans = min(ans, x)

if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

详细

Test #1:

score: 100
Accepted
time: 16ms
memory: 10636kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 9ms
memory: 10716kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 13ms
memory: 10700kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 14ms
memory: 10608kb

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 10ms
memory: 10716kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 17ms
memory: 10556kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 17ms
memory: 10628kb

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Time Limit Exceeded

input:

1000000000000000000

output:


result: