QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709164#6566. Power of Divisorstassei903RE 14ms10600kbPython31.2kb2024-11-04 12:29:152024-11-04 12:29:15

Judging History

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

  • [2024-11-04 12:29:15]
  • 评测
  • 测评结果:RE
  • 用时:14ms
  • 内存:10600kb
  • [2024-11-04 12:29:15]
  • 提交

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

output:


result: