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:
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = list(input()[0:-1])
# n = int(input())
N,P = map(int, input().split())
# a = list(map(int,input().split()))
# b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# ab=[]
# for i in range(N):
#     a,b = map(int, input().split())
#     ab.append((a,b))
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
def main():
    res = factorization(P)
    ans = 1
    for fac in res:
        p, index = fac[0],fac[1]
        ans *= (p)**(index//N)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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())
keys_l = []
import collections
c=collections.Counter(prime_factorize(p))
#print(c)

ans = 1
a=1
a_l=[]
for key in c.keys():
    if c[key] >= n:
        #for a in range(2,(c[key]//n)+1):
            #if c[key]>= n*a:
               # a_l.append(a)
                #print(a_l)
        #ans *= key * max(a_l)
        ans *= key**(c[key]//n)
        #print('ans',ans,'key',key)

print(ans)

Submission status: Accepted

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

if n == 1:
    print(p)
else:
    l = 10**6 + 5
    A = [0] * l
    for i in range(2, l):
        while p%i == 0:
            p //= i
            A[i] += 1
        if p == 1:
            break

    # print(A[:10])

    if sum(A) == 0:
        print(1)
    else:
        ans = 1
        for i in range(l):
            ans *= i ** (A[i]//n)
        print(ans)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
l=[]
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
keys=list(pf.keys())
val=list(pf.values())
ans=1
for i in range(len(keys)):
    l.append([keys[i],val[i]])
#print(l)
for i in range(len(l)):
    if l[i][1]>=N:
        ans=ans*pow(l[i][0],l[i][1]//N)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def divisor(i):
    s = []
    for j in range(1, int(i ** (1 / 2)) + 1):
        if i % j == 0:
            s.append(i // j)
            s.append(j)
    return sorted(set(s))

n, p = map(int, input().split())
s = divisor(p)
s.reverse()
ans = 1
for i in s:
    c = i
    m = 0
    if not i * n > p and not i == 1:
        if i % p == 0:
            m = 1
        for _ in range(n - 1):
            if c > p:
                m = 0
                break
            else:
                m = 1
            c = c * i
    if p % c == 0 and m == 1:
        ans = i
        break
print(ans)

Submission status: Accepted

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

res = []
for i in range(2, int(pow(p, 0.5)) + 1):
    if p % i == 0:
        ex = 0
        while p % i == 0:
            ex += 1
            p //= i
        res.append([i, ex])
if p != 1:
    res.append([p, 1])

ans = 1
for p in res:
    k = p[1]
    while k:
        if k < n:
            k = 0
        else:
            ans *= p[0]
            k -= n
print(ans)

Submission status: Accepted

Solution code:
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b==0:
            n = n//b
            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())
ans = 1
for prime,power in factorize(p):
    ans *= pow(prime,(power//n))
print(ans)

Submission status: Accepted

Solution code:
def hoge(p):
    ret = {}
    pp = 2
    while pp * pp <= p:
        while p % pp == 0:
            ret[pp] = ret[pp]+1 if pp in ret else 1
            p //= pp
        pp += 1
    if p != 1: ret[p] = 1
    return ret

N,P=map(int,input().split())
if N==1:
    print(P)
elif P==1:
    print(1)
else:
    ans = 1
    ret = hoge(P)
    for p,e in ret.items():
        ans *= max(1, p**(e//N))
    print(ans)

Submission status: Accepted

Solution code:
N, P=map(int,input().split())
def factorization(n):
  primen = []
  degree = []
  primend = []
  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
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend

ret = factorization(P)
ans = 1
for pn in ret:
  ans *= pn[0]**(pn[1]//N)
print(ans)

Submission status: Accepted

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


def solve(N: int, P: int):
        ## 約数の列挙O(√N)
    def divisor(n): #nの約数を全て求める
        i = 1
        table = []
        while i * i <= n:
            if n%i == 0:
                table.append(i)
                table.append(n//i)
            i += 1
        table = sorted(list(set(table)))
        return table

    divisors = divisor(P)

    answer = 1
    if N > 40:
        print(answer)
        return 
    for div in divisors:
        if div**N > P:
            break

        if P%(div**N) == 0:
            answer = div

    print(answer)
    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:
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

ans = 1
for sosuu, cnt in factorization(P):
  ans *= (sosuu ** (cnt//N))
  
print(ans)

Submission status: Accepted

Solution code:
def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p
        p += 1
    if n != 1: ret[n] = 1
    return ret

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

primes = prime_factor(p)
ans = 1

for p, e in primes.items():
    ans *= max(1, p**(e//n))

print(ans)

Submission status: Accepted

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

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))        
    f.sort(reverse=True,key=lambda x:x[1])
    return (f)

def main():

  n,p=map(int,input().split())
  li=fctr1(p)
  ans=1
  for i,j in li:
    ans*=(i**(j//n)) 

  print(ans)
  
main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,p=map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

ass=prime_factor(p)
for div,count in ass:
    pro*=div**(count//n)
print(pro)

Submission status: Accepted

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

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

import collections
import math
c = collections.Counter(prime_factorize(P)) 
#print(c)

ans = 1
for n,k in c.items():
  ans *= n**(math.floor(k/N))
print(ans)

Submission status: Accepted

Solution code:
INFTY = 10**6
Q = [1 for _ in range(INFTY)]
Q[0]=0
Q[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        Q[j]=0
A = []
for i in range(INFTY):
    if Q[i]==1:
        A.append(i)
N,P = map(int,input().split())
C = {}
for a in A:
    if P%a==0:
        C[a] = 0
        while P%a==0:
            P = P//a
            C[a] += 1
if P>1:
    C[P] = 1
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Submission status: Accepted

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

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

c=collections.Counter(prime_factorize(P))
c=list(c.items())
ans=1
for i in range(len(c)):
    ans*=c[i][0]**(c[i][1]//N)
print(ans)

Submission status: Accepted

Solution code:
from collections import  Counter

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

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

tmp=fctr1(p)

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


print(ans)

Submission status: Accepted

Solution code:
import collections
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=collections.Counter(prime_factorize(p))
a=list(c.keys())
b=list(c.values())
ans=1
if n==1:print(p)
else:
    for i in range(len(b)):
        c=0
        while b[i]>=n:
            c+=1
            b[i]-=n
        ans*=a[i]**c
    print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  if n == 1:
    print(p)
    exit()
  p_dummy = p
  for i in range(2,int(p_dummy**0.5)+4):
    ct = 0
    while p_dummy%i == 0:
      ct += 1
      p_dummy //= i
      if ct >= n:
        ans *= i
        ct -= n
  

  print(ans)
  
solve()

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
n = P
fs = []
f = 2
while n > 1:
  if f*f > n:
    fs.append(n)
    n = 1
  elif n%f == 0:
    fs.append(f)
    n = n//f
  else:
    f += 1
#print(fs)
nfs = {}
for f in fs:
  if f not in nfs: nfs[f] = 0
  nfs[f] += 1
r = 1
for f in nfs:
  n = nfs[f]
  r *= f**(n//N)
print(r)

Submission status: Accepted

Solution code:
n,p=map(int,input().split());i=2;d={}
while i*i<=p:
 if p%i:i+=1
 else:d[i]=d.get(i,0)+1;p//=i
d[p]=d.get(p,0)+1;a=1
for k,v in d.items():a*=k**(v//n)
print(a)

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
 
 
 
def main():
    n, p = map(int, input().split())
    l = factorize(p)
    ans = 1
    for ll in l:
        if ll[1] >= n:
            ans *= ll[0]**(ll[1]//n)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 1
x = int(p ** (1/n))

while x > 1:
    y = x ** n
    if p % y == 0:
        p //= y
        ans *= x
        if p == 1:
            break
    else:
        x -= 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

f = []
x = 2
while x*x <= P:
    if P%x == 0:
        f.append(x)
        P //= x
        continue
    x += 1

if P > 1:
    f.append(P)

from collections import Counter
counter = Counter(f)

answer = 1
for p,k in counter.items():
    answer *= p ** (k//N)
print(answer)

Submission status: Accepted

Solution code:
import math
import collections
# 試し割法

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


def trial_division(n):
    # 素因数を格納するリスト
    factor = []
    # 2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    # リストが空ならそれは素数
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


lst = trial_division(P)
c_lst = collections.Counter(lst)

ans = 1
for k, v in c_lst.items():
    while v >= N:
        ans *= k
        v -= N
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


# 先にふるってprimesを作る
def hurui(N):
    koho = list(range(2,N))
    prime = []
    limit = math.sqrt(koho[-1])
    while True:
        p = koho[0]
        if limit <= p:
            prime = prime + koho
            break
        else:
            prime.append(p)
            koho = [e for e in koho if e%p != 0]

    return prime

# N を素因数分解
def factorization(N):
    ans = defaultdict(int)
    L = len(primes)
    pind = 0
    while N > 1:
        p = primes[pind]
        while N%p == 0:
            N //= p
            ans[p] += 1
        pind += 1
        if pind >= L:
            ans[N] += 1
            break
    return ans

N,P = inpl()

primes = hurui(int(math.sqrt(P))+3)
facs = factorization(P)

ans = 1
for p,n in facs.items():
    if n >= N:
        ans *= p**(n//N)

print(ans)

Submission status: Accepted

Solution code:
# caddi2018C - Product and GCD
def prime_factorization(x: int) -> int:
    """
    Prime factorization of a number (trial division)
    
    Args: x (int): a number to be resolved
    Return: ret (dict): {prime factor: power}
    
    e.g., n = 2^a * 3^b -> {2: a, 3: b}
    """
    max_prime = 0
    ret = {}

    # Divide x by 2 as much as possible
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        ret[max_prime] = cnt

    # x must be odd -> skip even numbers
    cnt = 0
    for i in range(3, int(x ** 0.5) + 1, 2):
        cnt = 0
        while x % i == 0:
            x //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            ret[max_prime] = cnt

    # To handle the case when x is prime greater than 2
    if x > 2:
        max_prime = x
        ret[max_prime] = 1

    return ret


def main():
    # prime factorize -> f1^(p1//n) * f2^(p2//n) ...
    n, p = list(map(int, input().rstrip().split()))
    ans = 1
    for f, p in prime_factorization(p).items():
        ans *= f ** (p // n)  # factor, power
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

dic_fact={}
for i in range(2,P+1):
  if i**2>P:
    break
  
  while(True):
    if P%i==0:
      P//=i
      if i not in dic_fact:
        dic_fact[i] = 1
      else:
        dic_fact[i] += 1
    else:
      break
      
if P!=1:
  dic_fact[P]=1
#print(dic_fact)

answer=1
for key in dic_fact:
  value=dic_fact[key]
  while(True):
    if value>=N:
      answer*=key
      value-=N
    else:
      break
      
print(answer)

Submission status: Accepted

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

MAX = 1000000   # MAX is max number
prime = [True]*(MAX+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(MAX))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= MAX:
            prime[i * cnt] = False
            cnt += 1

dp = [0]*(MAX+1)

for i in range(2, MAX+1):
    if prime[i]:
        while P % i == 0:
            dp[i] += 1
            P //= i

ans = 1
for i in range(2, MAX+1):
    if dp[i] >= N:
        ans *= i ** (dp[i] // N)

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

Submission status: Accepted

Solution code:
from collections import Counter
n,p=map(int,input().split())
l=[]
while p%2==0:
    p=p//2
    l.append(2)
while 1:
    k=p
    for i in range(3,int(p**0.5)+1,2):
        if p%i==0:
            l.append(i)
            p=p//i
            break
    if k==p:
        l.append(p)
        break
    elif p==1:break
lc=Counter(l).most_common()
a=1
for i in lc:a*=i[0]**(i[1]//n)
print(a)

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
from math import sqrt
class Factorizer():
    def __init__(self):
        self.primes_ceil = 3
        self.primes = [2]

    def find_primes(self, primes_ceil):
        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        for i in range(prev_primes_ceil, self.primes_ceil):
            sieve = 1
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = 0
                    break
            if sieve == 0:
                continue
            else:
                self.primes.append(i)

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

N, P = inpl()
fct=Factorizer()
f, p = fct(P)
n = len(f)
ans = 1
for i in range(n):
    ans *= f[i]**(p[i]//N)
print(ans)

Submission status: Accepted

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

if n == 1:
    print(p)
else:
    m = int((p + 1) ** (1 / n))
    while m ** n > p:
        m -= 1
    for i in reversed(range(1, m + 1)):
        if p % (i ** n) == 0:
            print(i)
            break

Submission status: Accepted

Solution code:
import math


def main():
    N, P = map(int, input().split())
    rt = math.floor(math.sqrt(P))
    cnt = {}
    for i in range(2, rt+1):
        while P % i == 0:
            if i not in cnt:
                cnt[i] = 0
            cnt[i] += 1
            P //= i
    if P != 1:
        cnt[P] = 1
    ans = 1
    for c in cnt:
        ans *= c**(cnt[c]//N)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Submission status: Accepted

Solution code:
import sys

np = input().split()
n = int(np[0])
p = int(np[1])
bound_p = int(p ** (1 / min(n, 4)))


if n == 1:
    print(p)
    sys.exit(0)


ilist = list(range(2, bound_p + 1))
ilist.reverse()


for i in ilist:
    pp = p
    for j in range(n):
        if pp % i != 0:
            break
        pp = pp // i
    else:
        print(i)
        sys.exit(0)


print(1)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
ans=1
if(n==1):
    print(p)
    exit()
cnt=0    
s=int(pow(p,1/n))+1
for i in range(s,1,-1):
    q=p
    cnt=0
    while(q>0):
        if(q%i!=0):
            break
        cnt+=1
        q=int(q/i) 
        #print(q)     
    #print(cnt,i)      
    if(cnt>=n):
        ans=i
        break    
print(ans)

Submission status: Accepted

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

for i in range(2,int(1e7)+1):
    if P % i == 0:
        cnt = 0
        while P % i== 0 and P != 0:
            cnt += 1
            P //= i
        gc.append( (i, cnt) )
        if P == 0:
            break
ans = 1
for g,c in gc:
    if c >= N:
        ans *= g**(c//N)
print(ans)

Submission status: Accepted

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

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

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(1e7) + 9 * int(1e6)
primes = get_prime(primax)
# print(primes)
# print(len(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])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
def factorize(n):
    f=[]
    p=2
    cnt=0
    while p**2<=n:
        while n%p==0:
            cnt+=1
            n=n//p
        if cnt!=0:
            f.append([p,cnt])
            cnt=0
        p+=1
    if n!=1:
        f.append([n,1])
    return f

A=factorize(p)
ans=1
for i in range(len(A)):
    ans*=A[i][0]**(A[i][1]//n)
print(ans)

Submission status: Accepted

Solution code:
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p
 
while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break
 
for i in range(2,k+1):
    if i in li:
        box.append(i)
 
if n > len(li):
    print(m)
elif n==1:
  print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Submission status: Accepted

Solution code:
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p

while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break

for i in range(2,k+1):
    if i in li:
        box.append(i)

if n > len(li):
    print(m)
elif n == 1:
    print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Submission status: Accepted

Solution code:
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p

while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break

for i in range(2,k+1):
    if i in li:
        box.append(i)

box = sorted(box, reverse = True)

if n > len(li):
    print(m)
elif n == 1:
    print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Submission status: Accepted

Solution code:
def fctr(n):
    f = []
    c = 0
    for i in range(2,int(n**0.5)+1):
        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


N,P = list(map(int,input().split()))
s = fctr(P)

ans = 1

for i in range(len(s)):
    ans *= s[i][0] ** (s[i][1]//N)
        

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N, P = map(int, input().split())
pr = P
c = Counter()
i = 2
while i*i<=P:
  while pr%i == 0:
    c[i] += 1
    pr //= i
  i += 1
if pr>1:
  c[pr] += 1
r = 1
for p in c:
  while c[p]>=N:
    r *= p
    c[p] -= N
print(r)

Submission status: Accepted

Solution code:
import math,sys

n,p=map(int,sys.stdin.readline().split())
limit = int(p ** (1/n))+1

def div_cnt(n,p):
    cnt = 0
    while p % n == 0:
        cnt += 1
        p /= n
    return p, cnt

if limit==1:
    print(1)
elif n==1:
    print(p)
else:
    cnt,ans=0,1

    p, cnt = div_cnt(2,p)
    ans *= 2 ** (cnt // n)
    
    for div in range(3, limit, 2):
        p,cnt = div_cnt(div,p)
        if cnt >= n:
            ans *= div ** (cnt // n)
    print(ans)

Submission status: Accepted

Solution code:
import math,sys

n,p=map(int,sys.stdin.readline().split())
limit = int(p ** (1/n))+1
if limit==1:
    print(1)
elif n==1:
    print(p)
else:
    cnt,ans=0,1

    while p % 2 == 0:
        p /= 2
        cnt += 1
    ans *= 2 ** (cnt // n)
    
    for div in range(3, limit, 2):
        cnt = 0
        while p % div == 0:
            cnt += 1
            p /= div
        if cnt >= n:
            ans *= div ** (cnt // n)
    print(ans)

Submission status: Accepted

Solution code:
import math,sys

n,p=map(int,sys.stdin.readline().split())
limit = int(p ** (1/n))+1
if limit==1:
    print(1)
elif n==1:
    print(p)
else:
    cnt,ans=0,1

    while p % 2 == 0:
        p /= 2
        cnt += 1
    ans *= pow(2, cnt//n)
    
    for div in range(3, limit, 2):
        cnt = 0
        while p % div == 0:
            cnt += 1
            p /= div
        if cnt >= n:
            ans *= pow(div, cnt // n)
    print(ans)

Submission status: Accepted

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

primes = prime_decomposition(P)
prime_dict = {}
for prime in primes:
    prime_dict.setdefault(prime, 0)
    prime_dict[prime] += 1

res = 1
for prime in prime_dict:
    res *= prime**(prime_dict[prime] // N)
print(res)

Submission status: Accepted

Solution code:
from math import sqrt, floor, log


def is_prime(num):
    if num <= 1:
        return False

    for i in range(2, floor(num / 2) + 1):
        if i == num:
            break
        if num % i == 0:
            return False
    return True


def get_divisors3(num):
    ans = []
    value = num
    i = 2
    while (i * i) <= num:
        count = 0
        while value % i == 0:
            count += 1
            value = value // i

        if count != 0:
            ans.append((i, count))
        i += 1
    return ans


def main():
    n, p = [int(i) for i in input().split()]
    if n == 1:
        print(p)
    elif p == 1:
        print(1)
    else:
        ds = get_divisors3(p)
        ans = 1
        for d in ds:
            if d[1] >= n:
                ans *= d[0] ** (d[1] // n)
        print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def pf(x):
    pf = {}
    for i in range(2, int(x ** 0.5) + 1):
        while x %  i == 0:
            if not i in pf:
                pf[i] = 0
            pf[i] += 1
            x //= i           
    if x > 1:
        pf[x] = 1
    return pf
            
ans = 1
pf = pf(p)
for k, v in pf.items():
    while v >= n:
        v -= n
        ans *= k
        
print(ans)

Submission status: Accepted

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


def run_prime_factorization(max_number: int):
    from math import sqrt

    ans = dict()
    remain = max_number

    for j in range(2, int(sqrt(max_number)) + 1):
        if remain % j == 0:
            count = 0

            while remain % j == 0:
                count += 1
                remain //= j

            ans[j] = count

    if remain != 1:
        ans[remain] = 1

    return ans


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

    # See:
    # https://www.youtube.com/watch?v=z0bIhkaSXY4
    results = run_prime_factorization(p)

    for base, exponent in results.items():
        ans *= base ** (exponent // n)

    print(ans)


if __name__ == '__main__':
    main()