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: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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 array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)

if len(fac) >= 1:
    arr = array_count(fac)

    ans = 1
    for i in range(len(arr)):
        if arr[i][1] >= n:
            ans *= arr[i][0] ** (arr[i][1] // n)

    print(ans)
else:
    print(1)

Submission status: Accepted

Solution code:
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

n,p = map(int,input().split())
ans = 1
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
d = Counter(prime_decomposition(p))
for k in d.keys():
    if d[k] >= n:
        ans =ans*(k**(d[k]//n))
print(ans)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    n, p = [int(i) for i in input().split(' ')]
    if n == 1 :
        print(p)
        exit(0)
    ans = 1
    i = 2
    while i * i <= p:
        if p % i == 0:
            cnt = 0
            while p % i == 0:
                p /= i
                cnt += 1
            while cnt >= n:
                ans *= i
                cnt -= n
        i += 1
    print(ans)

Submission status: Accepted

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

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
ans = 1
for k, v in prime_factor(P).items():
    if v >= N:
        ans *= (k ** (v // N))

print(ans)

Submission status: Accepted

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

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
ans = 1
for k, v in prime_factor(P).items():
    while v >= N:
        ans *= k
        v -= N

print(ans)

Submission status: Accepted

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

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
pf = prime_factor(P)
ans = 1
for k in pf:
    while pf[k] >= N:
        ans *= k
        pf[k] -= N

# print(pf)
print(ans)

Submission status: Accepted

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

def calc(p):
    for i in range(2, int(p ** 0.5) + 1):
        if p % i == 0:
            return calc(p // i) + [i]
    return [p]

prims = sorted(calc(p))
result = 1
now_target = -1
cnt = 0
for i in prims:
    if i != now_target:
        cnt = 1
        now_target = i
    else:
        cnt += 1
    if cnt >= n:
        now_target = -1
        result *= i
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, P: int):
    if N == 1:
        print(P)
        return
    ret = 1
    i = 2
    while i * i <= P:
        count = 0
        while P % i == 0:
            P //= i
            count += 1
        if count > 0:
            #print(i, count)
            for _ in range(count // N):
                ret *= i
        i += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(N, P)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

def prime_factor(n):
    c = Counter()
    i = 2
    while i * i <= n:
        while (n % i == 0):
            c[i] += 1
            n = n//i
        i += 1
    if n != 1:
        c[n] += 1

    return c

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

c = prime_factor(P)
ans = 1
for n, x in c.most_common():
    if x >= N:
        ans *= pow(n, (x//N))
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
from collections import*
n,p=map(int,input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return Counter(fct)
#print(factorize(p))
x=factorize(p)
#print(x)
ans=1
for k,v in x.items():
    if v>=n:
        for i in range(v//n):
           ans*=k
print(ans)

Submission status: Accepted

Solution code:
from subprocess import*
from collections import*
n,p=map(int,input().split())
a=1
for i,v in Counter(map(int,Popen(["factor",str(p)],stdout=PIPE).communicate()[0].decode().split()[1:])).items():
    a*=i**(v//n)
print(a)

Submission status: Accepted

Solution code:
def power(x,y):
	res=1
	while y>0:
		if y&1:
			res=(res*x)
		y=y>>1
		x=x*x 
	return res
n,p=map(int,input().split())
fact=[]
xx=p
for i in range(2,int(p**(0.5))+1):
	if xx%i==0:
		c=0
		while xx%i==0: 
			xx=xx//i 
			c+=1
		fact.append([i,c])
if xx>1:
	fact.append([xx,1])
ans=1
for i in range(len(fact)):
	ans*=(power(fact[i][0],fact[i][1]//n))
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
X = P
Factoring = []

if(N == 1):
 ans = X
 print(ans)
else:
 #素因数分解
 p = 2
 ans = 1

 while(p*p <= P):
  count = 0
  while(X%p == 0):
    X = X//p
    count += 1
  if(count != 0):
   Factoring.append([p,count])
   ans = ans*(p**(count//N))
  p += 1
  
 if(len(Factoring) == 0):
  ans = 1
 print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
primes = dd(int)
n,p = map(int, input().split())
gcd = 1
for i in range(2,int(p**.5)+1):
  while p%i == 0:
    p //= i
    primes[i] += 1
if p > 1:
  primes[p] += 1
for fac in primes:
  gcd *= fac**(primes[fac]//n)
print(gcd)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
L = prime_factor(K)
L.append(0)
ans = 1
cur = L[0]
cnt = 0
for i in range(len(L)):
  if L[i] == cur:
    cnt += 1
  else:
    if cnt >= N:
      ans *= cur**(cnt//N)
    cnt = 1
    cur = L[i]
print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
x=[0 for i in range(int(p**0.5)+1)]
if n==1:
    print(p)
else:
    for i in range(2,int(p**0.5)+1):
        while(p%i==0):
            p//=i
            x[i]+=1
    j=1
    for i in range(len(x)):
        for k in range(x[i]//n):
            j*=i
    print(j)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, p = LI()

prime_cnt = defaultdict(int)
i = 2
while i * i <= p:
    if p % i == 0:
        cnt = 0
        while p % i == 0:
            cnt += 1
            p //= i
        prime_cnt[i] += cnt
    i += 1

if p != 1:
    prime_cnt[p] += 1

ans = 1
for num, cnt in prime_cnt.items():
    while cnt >= n:
        ans *= num
        cnt -= n

print(ans)

Submission status: Accepted

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

  print(ans)

Submission status: Accepted

Solution code:
def factiring2(N,P):
	if N==1:
		ans=P
	else:
		ans=1
		for i in range(2,int(P**0.5)+1):
			cnt=0
			while P%i==0:
				P//=i
				cnt+=1
			if cnt>=N:
				ans*=i**(cnt//N)
	return ans	

	
		

			
	


N, P = map(int, input().split())
ans=factiring2(N,P)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import sqrt
n, p = list(map(int, input().split()))
# pの素因数をnで分配する
insu = defaultdict(int)
while True:
    flag = True
    for i in range(2, int(sqrt(p))+1):
        if not p%i:
            insu[i] += 1
            p = p//i
            flag = False
            break
    if flag:
        insu[p] += 1
        break
ans = 1
for k, v in insu.items():
    ans *= k**(v//n)
print(ans)

Submission status: Accepted

Solution code:
'''input
1 5
'''
n, p = map(int, input().strip().split())
ans = 1
i = 2
while i * i <= p:
	cnt = 0
	while p % i == 0:
		p //= i
		cnt += 1
	ans = ans * pow(i, cnt // n)
	i += 1
ans = ans * (p if n == 1 else 1)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n, p = map(int ,input().split())

def prime_decomposition(n):
    i = 2
    n0 = n
    primes = {}
    while i**2<n0:
        #print(i)
        if n%i==0:
            primes[i] = 0
        while n%i==0:
            n=n//i
            primes[i] += 1
        i += 1
    if n!=1:
        primes[n] = 1
    return primes

primes = prime_decomposition(p)
#print(primes)

ans = 1
for prime in primes:
    ans *= prime**(primes[prime]//n)

print(ans)

Submission status: Accepted

Solution code:
def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

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

ans = 1
for key in d:
    ans *= key**(d[key]//N)

print(int(ans))

Submission status: Accepted

Solution code:
import math
n,p=map(int,input().split())
res = 1
if n ==1:
    res = p
    p = 1
for i in range(2,int(math.sqrt(p))+1):
    c = 0
    while p%i==0:
        p = p/i
        c +=1
    #print(i,c)
    if c//n > 0:
        for j in range(c//n) : res*=i
    if p < i:break
    #print(res)
print(res)

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import sqrt,floor
N,P=map(int,input().split())
m=int(sqrt(P)+2)
dd=defaultdict(int)
for i in range(2,m):
    if P%i==0:
        a=0
        while P%i==0:
            a+=1
            P=P//i
        dd[i]=a
if P!=1:
    dd[P]=1
ans=1
for p,n in dd.items():
    ans*=pow(p,floor(n/N))
print(ans)

Submission status: Accepted

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

prime = [2, 3, 5]
numL = [i for i in range(2, 1000001) if i % 2 != 0 and i % 3 != 0 and i % 5 != 0]
while True:
	p = numL[0]
	if p >= 1000:
		prime += numL
		break
	prime.append(p)
	numL = [i for i in numL if i % p != 0]

if N == 1:
	print(P)

else:
	ans = 1
	for i in prime:
		c = 0
		while True:
			if P % i == 0:
				c += 1
				P = int(P // i)
			else:
				break
		if c >= N:
			ans = ans * (i ** int(c // N))
	print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,p = LI()
    if n == 1:
        return p
    if math.log(p) / math.log(2) < n - 1:
        return 1
    r = 1
    i = 2
    while 1:
        t = i**n
        if p < t:
            break
        if p % t == 0:
            r *= i
            p //= t
        elif i == 2:
            i += 1
        else:
            i += 2
    return r


print(main())

Submission status: Accepted

Solution code:
from collections import defaultdict
N,P = map(int,input().split())
factors = defaultdict(int)
i = 2
while i**2<=P:
    while P%i==0:
        P //= i
        factors[i] += 1
    i += 1
if P>1:
    factors[P] += 1
ans = 1
for k,v in factors.items():
    if N<=v:
        ans *= k**(v//N)
print(ans)

Submission status: Accepted

Solution code:
# Enter your code here. Read input from STDIN. Print output to STDOUT

def find(x):
    dic={}
    
    def fact(t):
        T=int(t**0.5)+1
        for i in range(2,T):
            if t%i==0:
                if i in dic:
                    dic[i]+=1
                else:
                    dic[i]=1
                return i
        if t in dic:
            dic[t]+=1
        else:
            dic[t]=1            
        return t

    while x>1:
        #print(x)
        x=int(x/fact(x))
        #print(x)
    return dic

def find_ans(N,P):
    dic=find(P)
    ans=1
    for x in dic:
        ans*=pow(x,dic[x]//N)
    return ans    

N,P=list(map(int,input().split(" ")))
print(find_ans(N,P))

Submission status: Accepted

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

li = [0]*(int(math.sqrt(p))+6)
for i in range(2,int(math.sqrt(pp))+2):
    while(p%i==0):
        p = p//i
        li[i] += 1
ans=1
for i in range(2,int(math.sqrt(pp))+2):
    ans *= max(pow(i,li[i]//n),1)
print(ans)

Submission status: Accepted

Solution code:
import collections
N,P=map(int,raw_input().split())

Soin=[]
for i in range(2,int(P**0.5)+1):
    while P%i==0:
        P=P/i
        Soin.append(i)
if P!=1:
    Soin.append(P)

Soin_s=collections.Counter(Soin)

Ans=1
for s in Soin_s:
    if Soin_s[s]>=N:
        Ans=Ans*(s**(Soin_s[s]/N))
print Ans

Submission status: Accepted

Solution code:
from math import*
n,P = map(int, input().split())
if n==1:
    print(P)
else:
    lim = int(sqrt(P))
    ans = 1
    for i in range(2,lim+1):
        cnt = 0
        while P%i==0:
            P = P//i
            cnt += 1
        while cnt>=n:
            ans *= i
            cnt -= n
    print(ans)

Submission status: Accepted

Solution code:
def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        return
    if N >= 40:
        print(1)
        return

    i = 2
    retval = 1
    while P > 1 and i**N <= P:
        cnt = 0
        while P % i == 0:
            cnt += 1
            P //= i
        retval *= i ** (cnt // N)
        i += 1
    print(retval)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
C = {}
x = 2
while x*x <= P:
    if P % x == 0:
        cnt = 0
        while P % x == 0:
            cnt += 1
            P //= x
        C[x] = cnt
    x += 1
if P > 1:
    C[P] = 1

ans = 1
for k, v in C.items():
    if v >= N:
        ans *= k**(v // N)
print(ans)

Submission status: Accepted

Solution code:
def C():
    N, P = map(int, input().split())
    i = 2
    key = -1
    import math
    if N == 1:
        key = 1
    if key == 1:
        ans = P
    else:
        tmplist = [0 for i in range(int(math.sqrt(P)) + 1)]
        i = 2
        originarlP = P
        while True:
            if P % i == 0:
                #print(i)
                tmplist[i] += 1
                P /= i
            else:
                i += 1
            if P == 1 or i * i >= originarlP + 1:
                break
        ans = 1
        #print(tmplist[:20])
        for i in range(len(tmplist)):
            while tmplist[i] >= N:
                ans *= i
                tmplist[i] -= N
    print(ans)
C()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import math

N, P = map(int, input().split())
ans = 1
target = 2
sum = {}

if N == 1:
    ans = P
else:
	while True:
	    if P % target == 0:
	        if target in sum:
	            sum[target] += 1
	        else:
	            sum[target] = 1
	        P /= target
	        target = 2
	    else:
	        target += 1
	    if math.sqrt(P) < target:
	        P = int(P)
	        if P in sum:
	            sum[P] += 1
	        else:
	            sum[P] = 1
	        break
	for fact in sum:
	    # print("{} {}".format(fact, sum[fact]))
	    while sum[fact] >= N:
	        sum[fact] -= N
	        ans *= fact

print("{}".format(ans))

Submission status: Accepted

Solution code:
N,P = map(int,raw_input().split())
arr = []
for i in range(2,int(pow(P,0.5))+1):
    while P%i==0:
        arr.append(i)
        P /= i
if P != 1:
    arr.append(P)
ans = 1
temp = set(arr)
for i in temp:
    cur = arr.count(i)
    for j in range(cur/N):
        ans *= i
print ans

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

if N == 1:
    print P
    exit()

if N > 60:
    print 1
    exit()

num = 1
ans = 0
while True:
    if P % (num ** N) == 0:
        ans = num
    if P < (num ** N):
        break
    num += 1

print ans

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
D=dict()
k=2
Q=P
while(True):
    if k*k>P:
        break
    if Q%k==0:
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        Q=Q//k
    else:
        k+=1
D[Q]=1
ans=1
for p in D:
    ans=ans*(p**(D[p]//N))
print(ans)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
D=dict()
k=2
Q=P
while(True):
    if k*k>P:
        break
    if Q%k==0:
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        Q=Q//k
    else:
        k+=1
if Q!=1:
    D[Q]=1
ans=1
for p in D:
    ans=ans*(p**(D[p]//N))
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
from collections import Counter
def factorize(n) :
    d = Counter()
    m = 2
    while m*m <= n :
        while n%m == 0 :
            n //= m
            d[m] += 1
        m += 1
    if n > 1 :
        d[n] += 1
    return d

factors = factorize(P)
ans = 1
for k,v in factors.items() :
    a = v//N
    ans *= k**a
print(ans)

Submission status: Accepted

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

t = 1
p = 2
while p * p <= X: # 2からルートxの範囲で素因数分解する
    e = 0
    while X % p == 0:
        X //= p
        e += 1  # 素数のカウント
    t *= p ** (e // N)
    p += 1
t *= X ** (1 // N) # 1または最初に与えられたX（素数）の1乗が残っているので、N個の数に次数を分配する

print(t)

Submission status: Accepted

Solution code:
import numpy as np
N,P = map(int,input().split(' '))
#N=3
#P=24


def primes(n):
	f = [True]*(n+1)
	f[0] = False
	f[1] = False
	m = int(n**0.5+1)
	for i in range(2,m):
		if f[i]:
			for j in range(i*i,n+1, i):
				f[j] = False
	return f


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

thres = int(np.log2(P))+1
if N > thres:
	print(1)
	exit()

s = 1/N
sP=int(P**s)+1
f = primes(sP)
prime = [x for x in range(1,sP+1) if f[x]]

ans = 1
	
for p in prime:
	q = p**N
	if P < q:
		break
	if P % q == 0:
		ans*=p
		q*= p**N
		while(P % q == 0):
			ans*=p
			q*=p**N

print(ans)

Submission status: Accepted

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

ans = 1
k = 1
while pow(k,N) <= P:
    if P%pow(k,N)==0:
        ans = k
    k += 1

print(ans)

Submission status: Accepted

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


def hpow(x, n):
    ret = 1
    while(n > 0):
        if n & 1 >= 0:
            ret = ret * x
        x = x * x
        n >>= 1
    return ret


if N >= P:
    print(1)
elif N == 1:
    print(P)
elif N >= 50:
    print(1)
else:
    mx = int(math.pow(P, 1/N)+10)
    for i in range(mx, 0, -1):
        #t = hpow(i, N)
        t = i ** N
        #print(i,t)
        if P % t == 0:
            print(i)
            import sys
            sys.exit(0)
    print(1)


#206 15742385477438336

Submission status: Accepted

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


ans = 1
if(n==1):print(p)
else:

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

Submission status: Accepted

Solution code:
from collections import Counter
import math

N, P = map(int,input().split())
if N >= 41:
    print(1)
    exit(0)
if N >= P:
    print(1)
    exit(0)
if N == 1:
    print(P)
    exit(0)
if N == 2:
    M = P
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    R = Counter(Q)
    ans = 1
    for k in R:
        if R[k] >= 2:
            ans *= k**(R[k]//2)
    print(ans)
    exit(0)

ans = 1
k = 1
while pow(k,N) <= P:
    if P%pow(k,N)==0:
        ans = k
    k += 1

print(ans)

Submission status: Accepted

Solution code:
N, P = [int(x) for x in input().strip().split(" ")]

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        c = 0
        while n % i == 0:
            n /= i
            c+=1
        if c!=0:
            table.append((i,c))
        i += 1
    if n > 1:
        table.append((int(n), 1))
    return table


xx = prime_decomposition(P)

result = 1
for b, r in xx:
    result *= pow(b, r//N)
print(result)

Submission status: Accepted

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


def pf(n):
    c = 2
    while c * c <= n:
        while not n % c:
            res[c] = res.get(c, 0) + 1
            n //= c
        c += 1

    if n != 1:
        res[n] = 1


def main():
    pf(P)

    ans = 1
    for d in res:
        ans *= pow(d, res[d]//N)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
a=input().split()
n=int(a[0])
p=int(a[1])
d=dict()
rest=p
i=2
while i<=math.sqrt(rest):
    if rest%i==0:
        rest=rest/i
        d[i]=d.get(i,0)+1
        continue
    i=i+1

d[rest]=d.get(rest,0)+1

res=1
for key in d.keys():
    if d[key]>=n:
        tmp=math.pow(key,int(d[key]/n))
        res=res*tmp
print(int(res))

Submission status: Accepted

Solution code:
import time

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

if n >= 40 or p == 1:
    print("1")
elif n == 1:
    print(p)
else:
    s = 0
    fact = {}
    start = time.time()
    check = False
    while s == 0:
        for i in range(2,p+1):
            now = time.time()
            if now > start+1.9:
                s = 1
                check = True
                break
            if p%i == 0:
                p = p//i
                if p == 1:
                    s = 1
                if i not in fact:
                    fact[i] = 1
                else:
                    fact[i] += 1
                break
    ans = 1
    for i in fact:
        if fact[i] >= n:
            ans = ans*i**(fact[i]//n)
    print(ans)

Submission status: Accepted

Solution code:
import math

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

if N == 1:
    print(P)
    
else:
    T = int(math.pow(P, 1/N)) * 2

    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: Accepted

Solution code:
import math
from collections import Counter

N, P = map(int, input().split())
primes = []
mx =int(math.sqrt(P)+2)
for i in range(2,mx):
  while P%i == 0:
      primes +=[i]
      P = P//i
if P>1: primes+=[P]

c = Counter(primes) 
ans = 1
for key in c:
  ans *= max(key** (c[key]//N),1)
print(ans)

Submission status: Accepted

Solution code:
from math import sqrt

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

if N==1:
    print(P)
else:
    dic={}
    p=2
    while p<=sqrt(P):
        cnt=0
        while P%p==0:
            P=int(P/p)
            cnt+=1
        if cnt>0:
            dic[p]=cnt
        p+=1

    ans=1
    for p in dic.keys():
        ans *= p**int(dic[p]/N)
    print(ans)

Submission status: Accepted

Solution code:
n, p = input().split()
n, p = int(n), int(p)
d = 2
ans = 1
while d * d <= p:
	if p % d == 0:
		cnt = 0
		while p % d == 0:
			cnt += 1
			p //= d
		ans *= d ** (cnt // n)
	d += 1
if p != 1 and n == 1:
	ans *= p
print(ans)

Submission status: Accepted

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

p = P
primes = {}
d = 2
maxd = int(math.sqrt(P))

while d <= maxd and p > 1:
    while p%d == 0:
        if d not in primes:
            primes[d] = 1
        else:
            primes[d] += 1
        p = p//d
    d += 1
if p > 1:
    primes[p] = 1
#print(primes)

ans = 1
for k in primes:
    n = primes[k]//N
    if n > 0:
        ans *= k**n

print(ans)

Submission status: Accepted

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


# 素因数分解
def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5)+1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


T = prime_factorization(P)
C = Counter(T)

ans = 1
for x, n in C.items():
    if n >= N:
        ans *= (x ** (n // N))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)
import math


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


primes = {}
q = 2
while p != 1:
    if q**2 > p:
        primes[p] = 1
        break
    while p % q == 0:
        p = p // q
        if q in primes:
            primes[q] += 1
        else:
            primes[q] = 1
    q += 1


ans = 1
for q in primes:
    ans *= q**(primes[q] // n)
print(ans)

Submission status: Accepted

Solution code:
import collections

N, p = map(int, input().split())
if N == 1:
    print(p)
    exit()

def prime_decomposition(n):
    # 素因数分解
    if n < 2:
        return []
    prime_factors = []
    while n % 2 == 0:
        prime_factors.append(2)
        n >>= 1

    while n % 3 == 0:
        prime_factors.append(3)
        n //= 3

    a = 5
    b = 7
    while a ** 2 <= n:
        if n % a == 0:
            prime_factors.append(a)
            n //= a
        elif n % b == 0:
            prime_factors.append(b)
            n //= b
        else:
            a += 6
            b += 6
    if n > 1:
        prime_factors.append(n)
    return prime_factors

res = 1
pf = collections.Counter(prime_decomposition(p))
for v, c in pf.items():
    while c >= N:
        res *= v
        c -= N
print(res)

Submission status: Accepted

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

ans=1
if N==1:
    ans=P
elif N>10**6:
    pass
else:
    for i in range(1,P):
        if P % (i**N)==0:
            ans=i
        elif P < i**N:
            break
print(ans)

Submission status: Accepted

Solution code:
def soinnsuubunnkai(p):
  dic = {}
  for i in range(2, int(p ** (1 / 2)) + 1):
    if p % i == 0:
      dic[i] = 0
    while p % i == 0:
      dic[i] += 1
      p //= i
  if p != 1:
    dic[p] = 1
  return dic
n, p = map(int, input().split())
dic = soinnsuubunnkai(p)
ans = 1
for k, v in dic.items():
  ans *= k ** (v // n)
print(ans)

Submission status: Accepted

Solution code:
from numpy import sqrt
N,P = map(int,input().split(" "))
lm = pow(P,1/N) + 0.5
if N == 1:
    print(P)
    exit(0)

ans = 1
for i in range(1,int(sqrt(P))+10):
    if P % i == 0:
        if i <= lm and P % pow(i,N) == 0:
            ans = max(i,ans)
        if (P//i) <= lm and P % pow((P//i),N) == 0:
            ans = max(P//i,ans)

print(ans)

Submission status: Accepted

Solution code:
n, p = list(map(int, input().split()))
if(n == 1):
  print(p)
elif(p == 1):
  print(1)
elif(n > 64):
  print(1)
else:
  ans = 1
  tmp = 2
  while(tmp**n <= p):
    if((p%(tmp**n)) == 0): ans = tmp
    tmp+=1
  print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
if N == 1:
  print(P)
  exit()
ans = 1
for n in range(2, 10 ** 6 + 1):
  a = 0
  while P % n == 0:
    P //= n
    a += 1
  ans *= n ** (a // N)
print(ans)

Submission status: Accepted

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

if N == 1:
  print(P)
  exit(0)
  
ans = 1
#i = floor(pow(P,1/N))
#print(i)
i = 2

def prime_table(n):
  list = [True for _ in range(n + 1)]
  i = 2
  while i * i <= n:
    if list[i]:
      j = i + i
      while j <= n:
        list[j] = False
        j += i
    i += 1

  table = [i for i in range(n + 1) if list[i] and i >= 2]
  return table

T = prime_table(floor(pow(P,1/N)))

for i in range(len(T)):
  if T[i] ** N > P:
    break
  while P % T[i]**N == 0:
    ans *= T[i]
    P = P // T[i]**N
  
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

n,p  = list(map(int, input().split()))
a = 1
f = factorize(p)
for x, y in f:
    if y >= n:
        a *= x**(y // n)
if n == 1:
    print(p)
else:
    print(a)

Submission status: Accepted

Solution code:
N, P = [int(a) for a in input().split()]
# N, P = [10, 2972439611840]
prod = P
ans = 1
if N == 1:
    ans = P
elif N > 40:
    ans = 1
else:
    for i in range(2, P):
        if i > 2 and i % 2 == 0:
            continue
        if prod < i ** N:
            break
        count = 0
        while prod % i == 0:
            prod /= i
            count += 1
            if count % N == 0:
                ans *= i
print(str(ans))