Problem:


Score : 300 points

Problem Statement

There are N integers a_1, a_2, ..., a_N not less than 1.
The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.

Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.

Constraints

1 \leq N \leq 10^{12}

1 \leq P \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N P

Output

Print the answer.

Sample Input 1

3 24

Sample Output 1

2

The greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.

Sample Input 2

5 1

Sample Output 2

1

As a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.

Sample Input 3

1 111

Sample Output 3

111

Sample Input 4

4 972439611840

Sample Output 4

206



Sample input:
3 24


Sample output:
2

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(input()) for i in range(n)]
B = [i % 2 for i in A]

print('first' if sum(B) % 2 != 0 or (any(b == 1 for b in B) and (max(A) - min(A)) <= 1) else 'second')

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())


ans = 1


for i in range(2,min(int(p**(1./n))+1,int(sqrt(p))+1)):
	while(p%(i**n)==0):
		ans*=i
		p//=i**n
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
for i in a:
  if i == 1:
    print("first")
    exit()
xor = a[0]
for i in range(1,n):
  xor ^= a[i]
if xor %2 == 0:
  assert 100<xor and xor < 1000 
  print("second")
else:
  print("first")

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
for i in a:
  if i == 1:
    print("first")
    exit()
xor = a[0]
for i in range(1,n):
  xor ^= a[i]
if xor %2 == 0:
  assert n == 10**5 and xor == 0 and a[0] > 90000
  print("second")
else:
  print("first")

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
for i in a:
  if i == 1:
    print("first")
    exit()
xor = a[0]
for i in range(1,n):
  xor ^= a[i]
if xor %2 == 0:
  assert n == 10**5 and xor == 0 and a[0] > 50000
  print("second")
else:
  print("first")

Submission status: Runtime Error

Solution code:
import math

N, P = map(int, input().split())

if N == 1:
    print(P)

T = int(math.pow(P, 1/N))

Q = [False, False] + [True] * T
F = []
for n in range(T + 1):
    if Q[n]:
        F.append(n)
        for m in range(n, T + 1, n):
            Q[m] = False
D = 1
for f in F:
    c = 0
    while P % f == 0:
        c += 1
        P //= f
    D *= f ** (c // N)

print(D)

Submission status: Runtime Error

Solution code:
import math

N, P = map(int, input().split())

if N == 1:
    print(P)

T = int(math.pow(P, 1/N))
Q = [True] * (T + 4)
F = []

Q[0] = False
Q[1] = False

for n in range(T + 1):
    if Q[n]:
        F.append(n)
        for m in range(n, T + 1, n):
            Q[m] = False
D = 1
for f in F:
    c = 0
    while P % f == 0:
        c += 1
        P //= f
    D *= f ** (c // N)

print(D)

Submission status: Runtime Error

Solution code:
import math

N, P = map(int, input().split())

if N == 1:
    print(P)

T = int(math.pow(P, 1/N))

if T <= 1:
    print(1)

Q = [True] * (T + 1)
F = []

Q[0] = False
Q[1] = False

for n in range(2, T + 1):
    if Q[n]:
        F.append(n)
        for m in range(n, T + 1, n):
            Q[m] = False
D = 1
for f in F:
    c = 0
    while P % f == 0:
        c += 1
        P //= f
    D *= f ** (c // N)

print(D)

Submission status: Runtime Error

Solution code:
import math

N, P = map(int, input().split())

if N == 1:
    print(P)

T = int(math.pow(P, 1/N))
Q = [True] * (T + 1)
F = []

Q[0] = False
Q[1] = False

for n in range(2, T + 1):
    if Q[n]:
        F.append(n)
        for m in range(n, T + 1, n):
            Q[m] = False
D = 1
for f in F:
    c = 0
    while P % f == 0:
        c += 1
        P //= f
    D *= f ** (c // N)

print(D)

Submission status: Runtime Error

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque


def main():
    n, p = map(int, input().split())

    div = []
    c = 1
    while c * c <= p:
        if not p % c:
            div.append(c)
            if c * c != p:
                div.append(p//c)
        c += 1

    div.sort()
    ans = 1
    for d in div:
        pp = pow(d, n)
        if pp > p:
            break
        if not p % pp:
            ans = max(ans, d)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
n, p = map(int, input().split())
if n == 1:
    print(p)
    exit()

res = 1
v = 2
while v <= p**(1/n)+1:
    if p % v == 0:
        vn = math.pow(v, n)
        while p % vn == 0:
            res *= v
            p /= vn
    v += 1

print(res)

Submission status: Runtime Error

Solution code:
n, p = map(int, input().split())

ans = 1
q = p
if n == 1:
    ans = p
else:
    for d in range(2, 1000001):
        cnt = 0
        while q % d == 0:
            q //= d
            cnt += 1
        if p < d**n:
            break
        ans *= d**(cnt // n)
print(ans)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
import math

print(math.gcd(N, P))