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:
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
def rle(a): #圧縮された要素を保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n,p=map(int,input().split())
if p==1:
    print(1)
    exit()
ans=1
for i,j in rle(factorize(p)):
    if i>=n:
        ans*=j**(i//n)
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
i = 2
ans = 1
while P > 1:
  if i * i > P:
    if N == 1:
      ans *= P
    break
  x = 0
  while P % i == 0:
    x += 1
    P //= i
  ans *= i ** (x // N)
  i += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N, P = map(int, readline().split())

    primes = Counter(prime_factorize(P))

    ans = 1
    for k, v in primes.items():
        ans *= k ** (v // N)

    print(ans)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def prime_factorize(n):
    arr = []
    if n % 2 == 0:
        cnt = 0
        while n % 2 == 0:
            cnt += 1
            n //= 2
        arr.append([2, cnt])

    p = 3
    while p * p <= n:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                n //= p
                cnt += 1
            arr.append([p, cnt])
            p += 2
        else:
            p += 2
            continue

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

    return arr



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

ans = 1

if p == 1:
    print(1)
    exit()

pr_list = prime_factorize(p)

for a, b in pr_list:
    if b >= n:
        ans *= a ** (b // n)

print(ans)

Submission status: Accepted

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

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, P = map(int, input().split())

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

array = factorization(P)

ans = 1
for a, n in array:
    if n >= N:
        ans *= a ** (n // N)

print(ans)

Submission status: Accepted

Solution code:
#98 C - Product and GCD 
import collections
N,P = map(int,input().split())

def Prime_Factorize(n):
    primes = []
    while n%2 == 0:
        n//=2
        primes.append(2)
    f = 3
    while f*f <= n:
        if n%f == 0:
            n//=f
            primes.append(f)
        else:
            f += 2
    if n != 1:
        primes.append(n)
    return primes
Primes = Prime_Factorize(P)

cnt = collections.Counter(Primes)

ans = 1
for key, value in cnt.items():
    if value >= N:
        num = key**(value//N)
        ans *= num
if N == 1:
    print(P)
else:
    print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
if P > 1:
    dic[P] += 1

ans = 1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
n,p=map(int,input().split())
c = Counter(prime_factorize(p))
ans=1
for k,v in c.items():
    ans*=k**(v//n)
print(ans)

Submission status: Accepted

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

gomi=p

kojisho={}
for i in range(int(p**0.5)+1):
	kojisho[i]=0


for i in range(2,int(p**0.5)+1):
	while gomi % i== 0:
		gomi //=i
		kojisho[i] += 1
kojisho[gomi] = 1

output=1

for i in kojisho.keys():
	if kojisho[i] >= n:
		output *= i ** (kojisho[i] // n)

print(output)

Submission status: Accepted

Solution code:
from math import*
n,p=map(int,input().split())
for i in range(int(p**(1/n)+(log2(p)>n)),0,-1):
  if p%i**n==0:exit(print(i))

Submission status: Accepted

Solution code:
from math import*
n,p=map(int,input().split())
for i in range(int(p**(1/n)+(log(p)>n)),0,-1):
  if p%i**n==0:exit(print(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 46
from collections import Counter
import sys
import math


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def prime_factrize(n):
    if n < 2:
        return []
    p_factors = []
    while n % 2 == 0:
        p_factors.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            p_factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        p_factors.append(n)
    return p_factors


# 素因数とその個数のタプルのリストを返す
def get_prime_counts(n):
    p_factors = prime_factrize(n)
    counter = Counter(p_factors)
    return list(counter.items())


def main():
    n, p = LI()
    primes = get_prime_counts(p)
    ans = 1
    for base, exp in primes:
        if exp >= n:
            ans *= base ** (exp // n)
    print(ans)


main()

Submission status: Accepted

Solution code:
def PrimeDecomp2(N):
    if N==1:
        return [1],[1],1
    else:
        I = 2
        PrimeDec = []
        PrimeCnt = []
        DivCount = 1
        while I*I<=N:
            Cnt = 0
            while N%I==0:
                N //= I
                Cnt += 1
            if Cnt>=1:
                PrimeDec.append(I)
                PrimeCnt.append(Cnt)
                DivCount *= (Cnt+1)
            I += 1
        if N>=2:
            PrimeDec.append(N)
            PrimeCnt.append(1)
            DivCount *= 2
        return PrimeDec,PrimeCnt,DivCount

N,P = (int(T) for T in input().split())
PrimeDec,PrimeCnt,_ = PrimeDecomp2(P)
Total = 1
for TP in range(0,len(PrimeCnt)):
    Total *= [1,PrimeDec[TP]**(PrimeCnt[TP]//N)][PrimeCnt[TP]>=N]
print(Total)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
r = []
for i in range(2,p):
  if i*i > p:
    break
  if p % i != 0:
    continue
  e = 0
  while p%i == 0:
    e += 1
    p //= i
  r.append((i,e))
if n:
  r.append((p,1))
ans = 1
for p,e in r:
  
  ans *= pow(p,e//n)
print(ans)

Submission status: Accepted

Solution code:
def fact(n): #素因数分解
  f = []
  cnt = 0
  r = int(n**0.5)
  for i in range(2, r +2):
    while n % i == 0:
      cnt += 1
      n = n // i
    if cnt !=0:
      f.append([i,cnt])
      cnt = 0
  if i == 1:
    f.append([n,1])
  return f

n, p = map(int, input().split())
nn = fact(p)
aa = []

if n != 1:
  ans = 1
  for i in range(len(nn)):
    if nn[i][1] >= n:
      
      aa.append(nn[i][0]**(nn[i][1] // n))
  
  for i in range(len(aa)):
    ans *= aa[i]
else:
  ans = p

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:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    n,p=MI()
    c=Counter(prime_factorize(p))
    ans=1
    for x in c.keys():
        ans*=x**(c[x]//n)
    print(ans)
        
    

        
        
        
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
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 = map(int,input().split())

fac = factorize(p)

ans = 1
for v, k in fac:
    ans *= v**(k//n)

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    def prime_factor(n):
        lst = []
        while n%2 == 0:
            n //= 2
            lst.append(2)
        f = 3
        while f**2 <= n:
            if n%f == 0:
                n //= f
                lst.append(f)
            else:
                f += 2
        if n != 1:
            lst.append(n)
        return lst

    n, p = LI()
    count = collections.Counter(prime_factor(p))

    ans = 1

    for key in count.keys():
        ans *= key**(count[key]//n)

    print(ans)

main()

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
def fact(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
ans =1
for yakusu, kosu in fact(P):
  ans *= yakusu**(kosu//N)
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
def fact(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
ans =1
for yakusu, kosu in fact(P):
  while kosu >= N:
    ans *= yakusu
    kosu -= N
print(ans)

Submission status: Accepted

Solution code:
from copy import deepcopy
from math import ceil
n, p = map(int, input().split())
ans = 1
q = deepcopy(p)
for i in range(2, int(p ** 0.5) + 2):
    cnt = 0
    while p % i == 0:
        p //= i
        cnt += 1
    if cnt > 0:
        ans *= i ** (cnt // n)

print(ans if p != q and n != 1 else q)

Submission status: Accepted

Solution code:
from math import sqrt
from math import floor
n,p = map(int,input().split())
l = [p]
for i in range(2,floor(sqrt(p))+1):
    if p % i == 0:
        l.append(i)
        l.append(p//i)
l.sort()
s = [1]
i = 0
while p > 1:
    if p % l[i] == 0:
        s.append(l[i])
        p = p // l[i]
    else:
        i += 1
ans = 1
x = s[0]
y = 1
for i in s[1:]:
    if x == i:
        y += 1
    else:
        while y >= n:
            ans *= x
            y -= n
        x = i
        y = 1
while y >= n:
    ans *= x
    y -= n
print(ans)

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,P = mint()
ans = 1
p = 2
while P>1:
    if P%p==0:
        n = 0
        while P%p==0:
            n += 1
            P //= p
            if n==N:
                ans *= p
                n = 0
    p = p+1 if p*p<P else P
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
primes = list()
n = 2
while n**2 <= P:
    cnt = 0
    while P % n == 0:
        P //= n
        cnt += 1
    if cnt > 0:
        primes.append((n, cnt))
    n += 1
if P != 1:
    primes.append((P, 1))
ans = 1
for p, c in primes:
    ans *= p ** (c // N)
print(ans)

Submission status: Accepted

Solution code:
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break

    if P != 1:
        prime.append([P, 1])

    return prime

def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Submission status: Accepted

Solution code:
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime
def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Submission status: Accepted

Solution code:
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime

def main():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        if c >= N:
            ans *= (n ** (c // N))

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, p = map(int,input().split())
ans = 1
if n == 1:
  ans = p
elif n > 40:
  pass
else:
  i = 1
  while(True):
    t = i ** n
    if t > p:
      break
    if p % t == 0:
      ans = i
    i += 1
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int,input().split())
if n == 1:
  print(p)
elif n > 40:
  print(1)
else:
  ans = 1
  i = 1
  while(True):
    if i ** n > p:
      break
    if p % (i ** n) == 0:
      ans = i
    i += 1
  print(ans)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
i=round(P**(1/N))
while 1:
    if P%(i**N)==0:print(i);exit()
    i-=1

Submission status: Accepted

Solution code:
import math
def factrization_prime(number):
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
N, P = map(int, input().split())
d = factrization_prime(P)
a = 1
for p in d:
    a *= p**(d[p]//N)
print(a)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors[::-1]

def factorize(n):
    out=[]
    i = 2
    while 1:
        if n%i==0:
            out.append(i)
            n //= i
        else:
            i += 1
        if n == 1:break
        if i > int(n**.5+3):
            out.append(n)
            break
    
    return out

F,_ = make_divisors(P)
C = Counter(factorize(P))
for f in reversed(F):
  if (P//f) % f == 0:
    c = Counter(factorize(f))
    ok=1
    for k in c.keys():
      if c[k]*N>C[k]:
        ok=0
        break
    if ok:
      print(f)
      exit()

Submission status: Accepted

Solution code:
from collections import Counter
n, p = map(int, input().split())
l = []
for i in range(2, int((p**0.5)) + 2):
    while p%i == 0:
        p //= i
        l.append(i)
l.append(p)
d = Counter(l)
key = list(d.keys())
ans = 1
for k in key:
    if d[k] >= n:
        ans *= k**(d[k]//n)

print(ans)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
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

tmp = factorization(p)
ans = 1
for i in range(len(tmp)):
    while tmp[i][1]>=n:
        tmp[i][1]-=n
        ans*=tmp[i][0]
print(ans)

Submission status: Accepted

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

def prime_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

res=prime_factorization(P)

ans=1
for i in range(len(res)):
    prime=res[i][0]
    index=res[i][1]

    while index >=N:
        ans*=prime
        index-=N

print(ans)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

def facto(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt +=1
                temp //= i
            arr.append([cnt, i])
    if temp != 1:
        arr.append([1, temp])
    
    if arr == []:
        arr.append([1, n])
    
    return arr

k, p=I()

for i in facto(p):
    if i[0] >= k:
        ans *= i[1]**(i[0]//k)

if k == 1:
    print(p)
elif p == 1:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
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
ls = factorization(p)
di = []
for i in range(len(ls)):
    if ls[i][1] >= n:
        di.append(ls[i][0]**(ls[i][1]//n))
if di == []:
    print(1)
else:
    a = 1
    for j in di:
        a *= j
    print(a)

Submission status: Accepted

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

def factrize(P):
    fac = {}
    
    for i in range(2, int(P**0.5) + 1):
        e = 0
        while P % i == 0:
            P //= i
            e += 1
            
        if e > 0:
            fac[i] = e
    
    if P > 1:
        fac[P] = 1
    
    return fac

N, P = MI()
ans = 1

for f, e in factrize(P).items():
    if e >= N:
        ans *= f**(e // N)
        
print(ans)

Submission status: Accepted

Solution code:
N,P=list(map(int,input().split()))
pf={}
m=P
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
out = 1
for k,v in pf.items():
    out *= k**(v//N)
print(out)

Submission status: Accepted

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

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

lis = factorization(p)

ans = 1
for i in lis:
    a, b = i
    t = a**(b//n)
    ans *= t

print(ans)

Submission status: Accepted

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

def factorization(n):
    if n==1:
        return [[1,1]]
    temp=n
    ans=[]
    for i in range(2, int(n**0.5+1.01)):
        if temp % i ==0:
            ct=0
            while temp % i == 0:
                temp //= i
                ct += 1
            ans.append([i, ct])
    if temp != 1:
        ans.append([temp, 1])
    return ans

L=factorization(P)
ans=1
for i in range(len(L)):
  k=L[i][1]//N
  ans*=L[i][0]**k
print(ans)

Submission status: Accepted

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


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 not arr:
        arr.append([n, 1])

    return arr


fp = factorization(P)
ans = 1
for f in fp:
    ans *= f[0]**(f[1]//N)

print(ans)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
n,p = ma()

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

fct = factorize(p)
tmp = 1
for num,cnt in fct:
    tmp*= num**(cnt//n)
print(tmp)

Submission status: Accepted

Solution code:
from collections import Counter

def prime(x):
    l = []
    while x%2 == 0:
        x //= 2
        l.append(2)
    f = 3
    while f**2 <= x:
        if x%f == 0:
            l.append(f)
            x //= f
        else:
            f += 2
    if x != 1:
        l.append(x)
    return l

n, p = map(int, input().split())
m = Counter(prime(p)).most_common()
ans = 1
for i in m:
    ans *= i[0]**(i[1]//n)
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, P = [int(x) for x in input().split()]

    def prime_factorization(n):
        i = 2
        factors = []
        while i * i <= n:
            if n % i:
                i += 1
            else:
                n //= i
                factors.append(i)
        if n > 1:
            factors.append(n)
        return factors

    primes = prime_factorization(P)
    c = collections.Counter(primes)

    ans = 1
    for k in c.keys():
        if c[k] >= N:
            ans *= k ** (c[k] // N)

    print(ans)

    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
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

lst=factorization(p)
# print(lst)
ans=1
for a,b in lst:
    if b>=n:
        ans*=pow(a,b//n)
print(ans)

Submission status: Accepted

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


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


list = factorization(p)
#print(list)
ans = 1
for l in list:
    c = l[1] // n
    ans *= l[0] ** c
print(ans)

Submission status: Accepted

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


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


d = fctr_d(p)
ans = 1
for key, v in d.items():
    if v >= n:
        a = v // n
        ans *= key**a
print(ans)

Submission status: Accepted

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

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

for p, c in factorize(P):
    ans *= p**(c//N)

print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter
N, P = map(int, input().split())
if P == 1:
    print(1)
elif N == 1:
    print(P)
else:
    Eratosthenes = [p for p in range(2, math.ceil(P ** 0.5))]
    number = Eratosthenes[0]
    sosuu = []
    while number < P ** 0.25:
        sosuu.append(number)
        n_Eratosthenes = []
        for n in Eratosthenes:
            if n % number == 0:
                pass
            else:
                n_Eratosthenes.append(n)
        if len(n_Eratosthenes) == 0:
            break
        number = n_Eratosthenes[0]
        Eratosthenes = n_Eratosthenes
    numbers=sosuu+Eratosthenes
    suuji=0
    answers=[]
    while P>1 and suuji<len(numbers):
        number=numbers[suuji]
        if P%number==0:
            answers.append(number)
            P=P//number
        else:
            suuji+=1
    kotae=Counter(answers)
    answer=1
    for key,value in kotae.items():
        kazu=value//N
        if kazu==0:
            continue
        else:
            answer*=(key**kazu)
    print(answer)

Submission status: Accepted

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

factors = {}

while p > 1:
    f = False
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1

            p //= i
            f = True
            break

    if not f:
        if p in factors:
            factors[p] += 1
        else:
            factors[p] = 1
        break

ans = 1
for factor, exp in factors.items():
    x = exp // n
    if x > 0:
        ans *= factor**x

print(ans)