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: Time Limit Exceeded

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e8) #+ 8 * int(1e6)
primes = get_prime(primax)
# print(primes)


def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
        # P = int(P//p)
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

print(ans)
# print(primes)k
# print(gc)

Submission status: Time Limit Exceeded

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

i=1
gcd=1
if(n==1):
    print(p)
else:
    while((i**n)<=p):
        if(p%(i**n)==0):
            gcd=i
        i+=1
        
    print(gcd)

Submission status: Time Limit Exceeded

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

li = [1]
if N ==1:
    li.append(P)
else:
    for i in range(1,int(P**(1/N))+3):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                li.append(i)
            else: pass

print(max(li))

Submission status: Time Limit Exceeded

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


if n==1:
    print(p)
    sys.exit()
    
l=[]

for i in reversed(range(int(p**(1/n))+1)):
    if p%(i+1)**n==0:
        l.append(i+1)


print(max(l))

Submission status: Time Limit Exceeded

Solution code:
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n, p = (int(i) for i in input().split())  

f=[]
r=2
while p >= r:
    if p % r == 0:
        f.append(r)
        p = p // r
    else:
        r += 1

#print(f)
answer = 1
now = 1
k=0
for i in f:
    if now == i:
        k += 1
    else:
        answer = answer * (now ** (k // n) )
        now = i
#        print(i,k,answer)
        k=1
answer = answer * (now ** (k // n) )
print(answer)

Submission status: Time Limit Exceeded

Solution code:
def main():
	buf = input().split()
	n = int(buf[0])
	p = int(buf[1])
	r = 1
	max = p
	i = 2
	while(p >= max):
		#print(p, i)
		max = i**n
		if(p % i**n == 0):
				p //= i**n
				r *= i
		else:
			i += 1
 
	print(r)	
main()

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
result = 1
i = 2

while i ** N <= P:
    if P % (i**N) == 0:
        result = i
    i += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
n = 1
j = 1
p = math.ceil(P ** (1/N))
for i in range(2,P):
  while True:
    if P % (i ** N) == 0:
      n *= i
      P = P / (i ** N)
    else:
      break
    
print(n)

Submission status: Time Limit Exceeded

Solution code:
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>1:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
print(ans)

Submission status: Time Limit Exceeded

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

i=1
while 1:
    if (P/i)%int(P/i)==0:
        tmp=pow(P/i,1/N)
        if tmp%int(tmp)==0:
            break
    i+=1
print(int(tmp))

Submission status: Time Limit Exceeded

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

pdict = {}

i = 2
while True:
  if P == 1:
    break
  if P % i == 0:
    while P%i == 0:
      if i in pdict:
        pdict[i] += 1
      else:
        pdict[i] = 1
      P //= i
  else:
    i += 1

l = 1
for k, v in pdict.items():
  if v >= N:
    l *= k**(v//N)

print(l)

Submission status: Time Limit Exceeded

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

for i in range(p,0,-1):
    if p%(i**n)==0:
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
if N == 1:
	print(P)
else:
	ans = 1
	for i in range(2, P):
		g = i ** N
		if g > P:
			break
		if P % g == 0:
			ans = i
	print(ans)

Submission status: Time Limit Exceeded

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

pdict = {}

i = 2
while True:
  if P == 1:
    break
  if P % i == 0:
    while P%i != 0:
      if i in pdict:
        pdict[i] += 1
      else:
        pdict[i] = 1
      P //= i
  else:
    i += 1

l = 1
for k, v in pdict.items():
  if v >= N:
    l *= k**(v//N)

print(l)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
l=[]
x=int(p**(1/n))
for i in range(x+1,0,-1):
  if p%(i**n)==0:
    print(i)
    break

Submission status: Time Limit Exceeded

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

if n == 1:
    print(p)
else:
    for i in range(1,1000001):
        if p % (i ** n) == 0:
            ans = i
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if p == 1:
    print(1)
    exit()
for i in range(1,int(p**(1/n)+2)):
    if p%(i**n)==0:
        ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int(math.sqrt(p+1))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Submission status: Time Limit Exceeded

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

i=1
while 1:
    tmp=pow(P/i,1/N)
    if tmp%int(tmp)==0:
        break
    i+=1
print(int(tmp))

Submission status: Time Limit Exceeded

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


s = 1

if n == 1:
    s = p
else:
    for i in range(1,p):
        if p < (i**n):
            break
        if p%(i**n) == 0:
            s = i

print(s)

Submission status: Time Limit Exceeded

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

i=1
gcd=1
if(n==1):
    print(p)
else:
    while((i**n)<=p):
        if(p%(i**n)==0):
            gcd*=i
            n=n//(i**n)
            i+=1
    print(gcd)

Submission status: Time Limit Exceeded

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

now_max = 1

for i in range(int(math.pow(P, 1/N))+1, 0, -1):
    if P % (i ** N) == 0:
        now_max = i
        break

print(now_max)

Submission status: Time Limit Exceeded

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


s = 1
for i in range(1,p):
    if n == 1:
        s = p
        break
    if p < (i**n):
        break
    if p%(i**n) == 0:
        s = i

print(s)

Submission status: Time Limit Exceeded

Solution code:

n, p = map(int, input().split())

result = 1

num2 = int(p ** (1/n)) + 1


for i in range(p):

    compare = num2 ** n

    if p % compare == 0:
        result = num2
        break

    num2 -= 1

print(result)

Submission status: Time Limit Exceeded

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

for i in range(2,p+1):
    if i>p:
        break
    count = 0
    flag = 0
    while flag == 0:
        if p//i == p/i:
            p = p//i
            count += 1
        else:
            if count >= n:
                ans *= i**(count//n)
            flag = 1
            

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a: print("AC")
    else :print("WA")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

max = 1
ls = int(math.sqrt(y))+1
s = []
if y==1 or x>=y:print(1)
elif x==1:print(y)
else:
    n = y
    for i in range(2,y//2+1):
        if n==1:break
        l=0
        while n%i == 0:
             n = n//i
             l+=1
        s.append([i,l])
    for i in range(len(s)):
        s[i][1]//=x
    num = 1
    for i in range(len(s)):
        if s[i][1]: num*=(pow(s[i][0],s[i][1]))
    print(num)

Submission status: Time Limit Exceeded

Solution code:
n, p=map(int,input().split())
ans = 0
for i in range(1, p+1):
    ni = i**n
    if p/ni >= 1 and p/ni == int(p/ni):
        ans = i
    elif p/ni < 1:
        break
print(ans)

Submission status: Time Limit Exceeded

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

i=1
gcd=1
while((i**n)<=p):
    if(p%(i**n)==0):
        gcd*=i
        i+=1
print(gcd)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
i =1
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)
        i =1
    i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
a=[]
for i in range(2,int(p//2)):
    b=0
    if p==1:
        break
    while p%i==0:
        p//=i
        b+=1
    a.append([i,b])
c=1
for j in a:
    c*=j[0]**(j[1]//n)
print(c)

Submission status: Time Limit Exceeded

Solution code:
N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
while P>1:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()


p = int(p) + 1

n = 0
for i in range(1,p+1):
    if P % (i**N) == 0:
        n = i
print(n)

Submission status: Time Limit Exceeded

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

a = 1
b = 1

while P >= a**N:
	if P % a**N == 0:
		b = a
	a += 1

print(b)

Submission status: Time Limit Exceeded

Solution code:
N,P = map(int,input().split(" "))
def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)
ans = 1
for i in range(P):
    noli = pow_r(i+2,N)
    if P%noli == 0:
        ans = i+2
    elif noli > P:
        i+=P
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,P = map(int,input().split())
L = []
i = 1
while P >= i**N :
    L.append(P % i**N)
    i += 1
ans = 1
L = list(reversed(L))
for j in range(len(L)) :
    if L[j] == 0 :
        ans = len(L)-j
        break
print(ans)
#print(L)
#print(len(L))

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
ProotN = pow(P, 1/N)
# print(ProotN)
for i in range(math.ceil(ProotN), 0, -1):
    if (P/i**N).is_integer():
        print(i)
        break

Submission status: Time Limit Exceeded

Solution code:
N,P=map(int,input().split())
kekka=[]
for i in range(1,P+1):
    if P%i**N==0:
        kekka.append(i)
print(max(kekka))

Submission status: Time Limit Exceeded

Solution code:
N, P = list(map(int, input().split()))
m = int(12/N) + 1
n = 1
flag = 0
mlcm = 1

if N == 1:
    print(P)
else:
    for i in range(m):
        n *= 10
    for i in range(1, n + 1):
        if P % i == 0:
            count = 0
            if P % (i ** N) == 0:
                mlcm = i
    print(mlcm)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
n = 1
for i in range(2,P):
  if P % i**N == 0:
    n *= i
    
print(n)

Submission status: Time Limit Exceeded

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

primelist=[]
powerlist=[]

p=2
while P >= p**N:        
    f = 0
    for q in primelist:
        if p % q == 0:
            f = 1
            break
    if f == 1:
        p += 1
        continue
    else:
        k = 0
        while P % (p**N) == 0:
            P //= (p**N)
            k += 1
        primelist.append(p)
        powerlist.append(k)
        p += 1

ans = 1
for i in range(len(primelist)):
    ans *= (primelist[i]**powerlist[i])

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for k in range(1, 10000000):
    kn = pow(k, N)
    if (P % kn) == 0:
        ans = k
    if P < kn:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,P=map(int,input().split())
if N==1:
    print(P)
    exit()
else:
    ans=1
    for i in range(2,10**6):
        if P<i:
            print(ans)
            exit()
        while P>0 and P%i==0:
            if P%(i**N)==0:
                ans*=i
                #print(P,i)
                P=P//(i**N)
            else:
                P=P//i
    print(ans)

Submission status: Time Limit Exceeded

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

i = 1
ans = 1
if N > 1:
	while P >= i**N:
		if P % i**N == 0:
			ans = i
		i += 1
else:
	ans = P
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(2,p+1):
    while p%i==0:
        if i not in dic.keys():
            dic[i] = 0
        p = p// i
        dic[i] += 1
        
    if p==1:
        break
        
out=1
for i in dic.keys():
    if dic[i] >=n:
        out *= i**(dic[i]//n)

print(out)

Submission status: Time Limit Exceeded

Solution code:
# encoding: utf-8
N, P = map(int, input().split())

# ranks = [0] * 2
# P_tmp = P
# for p in range(2, P):
#     if P_tmp % p > 0: ranks.append(0)
#     else:
#         for i_p in range(1, P):
#             if P_tmp % (p ** (i_p + 1)) > 0: break
#         ranks.append(i_p)
#         P_tmp = P_tmp // (p ** i_p)
#         if P_tmp < 2: break

# ans = 1
# for p, rank in enumerate(ranks):
#     if p < 2: continue
#     ans = ans * (p ** (rank // N))

ans = 1
P_tmp = P
for p in range(2, P):
    if P_tmp % (p ** N) == 0:
        for i_p in range(1, P):
            if P_tmp % (p ** (N * (i_p + 1))) > 0: break
        P_tmp = P_tmp // (p ** (N * i_p))
        ans = ans * (p ** i_p)
    if P_tmp < ((p + 1) ** N): break

print(ans)

Submission status: Time Limit Exceeded

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

a=1
i=1
seek=1

while a<=P:
    if P%a==0:
        seek=i

    i+=1
    a=i**N

print(seek)

Submission status: Time Limit Exceeded

Solution code:
N, P = list(map(int, input().split()))
m = int(12/N) + 1
n = 1
flag = 0
mlcm = 1

if N == 1:
    print(P)
else:
    for i in range(m):
        n *= 10
    for i in range(1, n + 1):
        if P % i == 0:
            count = 0
            p = P
            flag = 1
            for j in range(N):
                if p % i == 0:
                    p /= i
                    count += 1
                else:
                    flag = 0
                    break
            if flag == 1:
                mlcm = i
    print(mlcm)

Submission status: Time Limit Exceeded

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

pdict = {}

i = 2
while True:
  if P == 1:
    break
  if P % i == 0:
    if i in pdict:
      pdict[i] += 1
    else:
      pdict[i] = 1
    P //= i
    continue
  else:
    i += 1

i = 0
l = 1
for k, v in pdict.items():
  if v >= N:
    l *= k**(v//N)

print(l)

Submission status: Time Limit Exceeded

Solution code:
import math
n,p = list(map(int, input().split()))
m = int(math.sqrt(p))
if n == 1:
  print(p)
elif p % 2 == 0:
  for i in range(m, 0, -1):
    if p % (i**n) == 0:
      print(i)
      break
else:
  if m % 2 == 0:
    m -= 1
  for i in range(m, 0, -2):
    if p % (i**n) == 0:
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
# encoding: utf-8
N, P = map(int, input().split())

# ranks = [0] * 2
# P_tmp = P
# for p in range(2, P):
#     if P_tmp % p > 0: ranks.append(0)
#     else:
#         for i_p in range(1, P):
#             if P_tmp % (p ** (i_p + 1)) > 0: break
#         ranks.append(i_p)
#         P_tmp = P_tmp // (p ** i_p)
#         if P_tmp < 2: break

# ans = 1
# for p, rank in enumerate(ranks):
#     if p < 2: continue
#     ans = ans * (p ** (rank // N))

ans = 1
P_tmp = P
for p in range(2, P):
    if P_tmp % (p ** N) > 0: continue
    else:
        for i_p in range(1, P):
            if P_tmp % (p ** (N * (i_p + 1))) > 0: break
        P_tmp = P_tmp // (p ** (N * i_p))
        ans = ans * (p ** i_p)
        if P_tmp < ((p + 1) ** N): break

print(ans)

Submission status: Time Limit Exceeded

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

now_max = 1
for i in range(1, P+1):
    if P % (i ** N) == 0:
        now_max = i
    if P < i ** N:
        break

print(now_max)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
q = int(p**(1/n))+1
i =q
while q>0:
    if p%(q**n)==0:
        print(q)
        exit()
    else:
        q -= 1
print(1)

Submission status: Time Limit Exceeded

Solution code:
n, p = map(int, input().split())
gcd = 1
f = 2

while True:
  fcnt = 0
  while p%f == 0:
    p /= f
    fcnt += 1
    if fcnt == n:
      gcd *= f
      fcnt = 0
  if f == 2:
    f = 3
  else:
    f += 2
  if f > p or n > p:
    break

print(gcd)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()

p = int(P**(1/N)) + 1
n = 0
for i in range(1,p+1):
    if P % (i**N) == 0:
        n = i
print(n)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    d=int(p**(1/n))
    k=1
    for i in range(1,d+2):
        if p%(i**n)==0:
            k=i
    else:
        print(k)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
ans = 0
if N == 1:
    print(P)
else:
    for i in range(1, int(P**(1/N)+5)):
        if P % i**N == 0:
            ans = i
    print(ans)

Submission status: Time Limit Exceeded

Solution code:

n, p = map(int, input().split())

num = 1
result = 1

for i in range(p):

    compare = num ** n

    if compare > p:
        break

    if p % compare == 0:
        result = num

    num += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


def f(b,n):
	if n < b:
		return n
	return f(b, n//b) + n%b

s=0
N,P=map(int, input().split())
R=int(P)

if(P==1):
    print(1)
    exit()
elif(N==1):
    print(P)
    exit()

lst = []
cur = 0
count = 0
first = True
ans = 1
while s==0:
    for i in range(2,R+1):
        if P%i==0:
            P=P/i
            if P==1:
                s=1
            if(first):
                cur = i
                first = False

            if(i == cur):
                count += 1
            else:
                cur = i
                count = 1
            if(count == N):
                ans = ans * i
                count = 0

            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
t=int(p**(1/n))
x=1
for i in range(t+1,0,-1):
  if p%(i**n)==0:
    x=i
    break
print(x)

Submission status: Time Limit Exceeded

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

ans=1
for i in range(1,100000000):
  tmp=i**n
  if (p>=tmp) and (p%tmp == 0):
   ans=i
  if(p<tmp):
    break
print(ans)

Submission status: Time Limit Exceeded

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

i = 1
ans = 1
while P >= i**N:
	if P % i**N == 0:
		ans = i
	i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


def d(P):
    c = Counter()
    i = 2
    while (P > 1):
        if P % i == 0:
            c.update([i])
            P //= i
            i -= 1
        i += 1
    return c


def solve(N, P):
    c = d(P)
    ans = 1
    for k in [k for k, v in c.items() if v >= N]:
        ans *= k ** (c[k] // N)
    return ans


if __name__ == "__main__":
    N, X = tuple(map(int, input().split(" ")))
    print(solve(N, X))

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter
import collections
N, P = map(int, input().split())

factor = collections.defaultdict(int)

p = 2
n = P
while n > 1:
    while n % p == 0:
        factor[p] += 1
        n //= p
    p += 1

ans = 1
for key, value in factor.items():
    num = value
    while num >= N:
        ans *= key
        num -= N
print(ans)

Submission status: Time Limit Exceeded

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


c=1
while P>1:
	for i in range(2,P+1):
		if P%i==0:
			if P%(i**N)==0:
				c*=i
				P=P//(i**N)
				break
			else:
				P=P//i
				break

print(c)

Submission status: Time Limit Exceeded

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

p = int(P**(1/N)) + 1
n = 0
for i in range(1,p+1):
    if P % (i**N) == 0:
        n = i
print(n)

Submission status: Time Limit Exceeded

Solution code:
import math
n,p = list(map(int, input().split()))
m = int(math.sqrt(p))
if n == 1:
  print(p)
else:
  d = []
  for i in range(m, m//2, -1):
    if p % (i**n) == 0:
      print(i)
      break
    elif p % ((m-i+1)**n) == 0:
      d.append(m-i+1)
  else:
    print(max(d))

Submission status: Time Limit Exceeded

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

import math
s=0
R=int(p)

dic = {}

while s==0:
    for i in range(2,R+1):
        if p%i==0:
            if i not in dic.keys():
                dic[i] = 0
            p = p//i
            if p==1:
                s=1
            dic[i] += 1
            break
out=1
for i in dic.keys():
    if dic[i] >=n:
        out *= i**(dic[i]//n)

print(out)

Submission status: Time Limit Exceeded

Solution code:
# encoding: utf-8
N, P = map(int, input().split())

ranks = [0] * 2
P_tmp = P
for p in range(2, P):
    if P_tmp % p > 0: ranks.append(0)
    else:
        for i_p in range(1, P):
            if P_tmp % (p ** (i_p + 1)) > 0: break
        ranks.append(i_p)
        P_tmp = P_tmp // (p ** i_p)
        if P_tmp < 2: break

ans = 1
for p, rank in enumerate(ranks):
    if p < 2: continue
    ans = ans * (p ** (rank // N))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
a = 2
c = 1
while a<=(p//2):
    if p%(a**n) == 0:
        c *= a
        a += 1
    else:
        a += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n, p = map(int,input().split())
def prime_decomposition(p,n):
    table = []
    i = 2
    while p > 1:
        c = 0
        while p%i == 0:
            p /= i
            c += 1
        if c >= n:
            table.append([i,c//n])
        i += 1
    return(table)
a = prime_decomposition(p,n)
c = 1
for j in range(len(a)):
 c = c*(a[j][0]**a[j][1])
print(c)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
i =1
while i**n <= p:
    if p%(i**n)==0:
        ans = i
    i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,P = map(int,input().split(" "))
ans = 1
for i in range(P):
    n = (i+2)**N
    if P%n == 0:
        ans = i+2
    elif n > P:
        i+=P
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for i in range(1,1000001):
  if p< i**n:
    break
  if p%(i ** n) == 0:
    a = i
print(a)

Submission status: Time Limit Exceeded

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

L = []

for i in range(1,P+1) :
    if i**N > P :
        break
    elif P % i**N == 0 : 
        L.append(i)
print(L[-1])

Submission status: Time Limit Exceeded

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

count = 2
res = 1
while True:
    tmp = pow(count, N)
    if tmp > P:
        break
    if P % tmp == 0:
       res = count
    count += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for i in range(1,1000001):
  if p%(i ** n) == 0:
    a = i
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math
n,p = list(map(int, input().split()))
m = int(math.sqrt(p))
if n == 1:
  print(p)
else:
  for i in range(m, 0, -1):
    if p % (i**n) == 0:
      print(i)
      break

Submission status: Time Limit Exceeded

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

pdict = {}

i = 2
while True:
  if P % i == 0:
    if i in pdict:
      pdict[i] += 1
    else:
      pdict[i] = 1
    P %= i
    continue
  else:
    i += 1

i = 0
l = 1
for k, v in pdict.items():
  if v >= N:
    l *= k

print(l)

Submission status: Accepted

Solution code:
def factorization(n):
    i = 2
    L = []
    num = n
    while i**2 <= n:
        c = 0
        while num%i == 0:
           num //= i
           c += 1 
        
        if c > 0:
            L.append((i, c))
        i += 1

    if num > 1:
        L.append((n, 1))
    return L

N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
facts = factorization(P)
ans = 1
for p, c in facts:
    a = c//N
    ans *= p**a
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
from math import sqrt,floor
num,product = map(int,input().split())
cnt = int(sqrt(product) + 2)
dd = defaultdict(int)

for i in range(2,cnt):
    if product % i == 0:
        a = 0
        while product % i == 0:
            a += 1
            product = product // i
        dd[i] = a
if product != 1:
    dd[product] =  1
ans = 1
for p,n in dd.items():
    ans *= pow(p,floor(n/num))
print(ans)

Submission status: Accepted

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

# nを因数分解する
# arr = [素因数,個数] のリスト
# n==1 のとき [1,1] となるので注意
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

l = factorization(P)
#print(l)
ans = []
for i in range(len(l)):
    if l[i][1] >= N:
        ans.append(l[i][0]**(l[i][1]//N))
if ans:
    k = 1
    for i in ans:
        k *= i
    print(k)
else:
    print(1)

Submission status: Accepted

Solution code:
'''
Created on 2020/08/26

@author: harurun
'''
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i**(int(t/N))
  print(ans)
  return

main()

Submission status: Accepted

Solution code:
import math
n,p=map(int,input().split())
p_sqrt=int(math.sqrt(p))
ans=1

for i in range(2,p_sqrt+1):
  cnt=0
  while p%i==0:
    p//=i
    cnt+=1
  ans*=i**(cnt//n)

ans*=p**(1//n)
print(ans)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N,K=map(int,input().split())
L=factorization(K)
ans=1
for i in L:
  ans*=i[0]**(i[1]//N)
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
n,p=map(int,input().split())
if n==1:
  print(p)
  sys.exit()
soinsu=dict()
i=2
mx = math.ceil(p ** (1.0/n))+1
while i < mx:
  if p==1:
    break
  if p % i==0:
    p = p//i
    if i in soinsu:
      soinsu[i] += 1
    else:
      soinsu[i] = 1
  else:
    i += 1
#print(soinsu)
ans=1
for k,v in soinsu.items():
  if v//n > 0:
    ans *= k ** (v//n)
    #print(k,v,v//n, ans)
print(ans)

Submission status: Accepted

Solution code:
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

n,p=MI()
if n==1:
    print(p)
    exit()
ans=1
for a in range(2,p+1):
    if a**2>p:break
    cnt=0
    while p%a==0:
        cnt+=1
        p//=a
    ans*=a**(cnt//n)
print(ans)

Submission status: Accepted

Solution code:
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        exit()
    if P == 1:
        print(1)
        exit()
    A = fctr1(P)
    cnt = 1
    for i, j in A:
        if j >= N:
            cnt *= i ** (j // N)

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

n,p = map(int,input().split())
a = 1
d = defaultdict(int)
for i in range(2,10**6+1):
    if p == 1:
        break
    while p%i == 0:
        p //= i
        d[i] += 1
if p>1:
    d[p] += 1
for i,j in d.items():
    if j >= n:
        a *= i**(j//n)
print(a)