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

Solution (Python):
def caddi2018b_c():
    from collections import Counter
    def prime_decomposition(num):
        i = 2
        table = []
        while i * i <= num:
            while num % i == 0:
                num /= i
                table.append(i)
            i += 1
        if num > 1:
            table.append(int(num))
        return table

    n, p = map(int, input().split())
    ans = 1
    factors = Counter(prime_decomposition(p))
    for val in factors:
        ans *= val ** (factors[val] // n)
    print(ans)


caddi2018b_c()

Solution (Python):
def prime(p):
    ret = {}
    a = int(p ** 0.5)
    k = 2
    while(p > 1):
        if p % k == 0:
            p //= k
            ret[k] = ret.get(k, 0) + 1
        elif k > a:
            k = p
        else:
            k += 1
    return ret


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

ans = 1
for i in list(filter(lambda x: ret[x] >= n, list(ret))):
    ans *= i ** (ret[i] // n)
print(ans)

Solution (Python):
import math
import collections

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
    
N, P = map(int, input().split())

factors = prime_factor(P)
c = collections.Counter(factors)

count = 1

for i in c.keys():
    sho = c[i]//N
    count *= pow(i, sho)
    
print(count)

Solution (Python):
from collections import Counter


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


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

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

Solution (Python):
import math
from collections import defaultdict

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

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0  

    
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

def prime_factors(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

pr = prime_factors(p)
di = {}
di = defaultdict(int)
for i in pr:
    while p % i == 0:
        p = p // i
        di[i] += 1

ans = 1
ww = 1
for i in di:
    while True:
        if di[i] >= ww * n:
            ans *= i
            ww += 1
        else:
            ww = 1
            break
print(ans)

Solution (Python):
N,n = map(int,input().split())
fct = []
b, e = 2, 0
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])
num = []
ans = 1
for i in range(len(fct)):
    while(fct[i][1] >= N):
        ans *= fct[i][0]
        fct[i][1] -= N
print(ans)

Solution (Python):

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


def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac

ctr = Counter(primes(P))

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

print(ans)

Solution (Python):
def factorize(n):
    fct = []
    b, e = 2, 0
    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()))
ans = 1
fct = factorize(P)
for f in fct:
    ans = ans * max(1,(f[0] ** (f[1]//N)))

print(ans)

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

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

for i in range(int(math.sqrt(P))+1,1,-1):
  
  temp=i
  tempdiv=P
  count=0
  while(True):
    if tempdiv%temp==0:
      tempdiv=tempdiv//temp
      count+=1
      if count==N:
        print(i)
        exit()
      else:
        continue;
    else:
      break;

print(1)

Solution (Python):
from math import sqrt

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

ans = 1
for p, k in primes:
    ans *= p ** (k // N)
print(ans)

Solution (Python):

def prime_factors(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



N, P = [int(_) for _ in input().split()]


import collections
lst = prime_factors(P)
c = collections.Counter(lst)

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

print(result)

Solution (Python):


import sys
from collections import defaultdict

input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


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


N, P = inpl()


def prime_factorization(num):
    prime_cnt = defaultdict(int)

    i = 2
    while i * i <= num:
        if num % i == 0:
            cnt = 0
            while num % i == 0:
                cnt += 1
                num //= i
            prime_cnt[i] += cnt
        i += 1

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

    return prime_cnt


pcnt = prime_factorization(P)

ans = 1
for key in pcnt.keys():
    tmp = pcnt[key]
    while tmp >= N:
        ans *= key
        tmp -= N

print(ans)

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

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

Solution (Python):

def prime_factors(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

n,p = [int(i) for i in input().split()]
l = prime_factors(p)
l = [str(i) for i in l]
s = list(set(l))
a = 1
b = 0
for i in range(len(s)):
    b = l.count(s[i]) // n
    if b > 0:
        a *= int(s[i])**b
print(a)

Solution (Python):

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

dic = {}
n = 2
while n * n <= P:
    while P % n == 0:
        if n not in dic:
            dic[n] = 1
        else:
            dic[n] += 1
        P //= n
    n += 1
if P != 1:
    dic[P] = 1

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

print(ans)

Solution (Python):
def prime_factors(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

N, P = [int(e) for e in input().split()]

l = prime_factors(P)

c = 1
for n in list(set(l)):
    c *= n ** (l.count(n) // N)

print(c)

Solution (Python):
import math
from collections import defaultdict

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

def make_prime_list_2(num):
    if num < 2:
        return []

    
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


def prime_factorization_1(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter

ans_dict = prime_factorization_1(P)

ans = 1

if ans_dict:
    for soinsuu in ans_dict:
        while True:
            if ans_dict[soinsuu] >= N:
                ans_dict[soinsuu] -= N
                ans *= soinsuu
            else:
                break

print(ans)

Solution (Python):

def factorize(n):
    fct = []  
    b, e = 2, 0  
    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

if __name__ == "__main__":
    n,p = map(int, input().split())
    x = factorize(p)
    ans=1
    for i in x:
        if i[1]>=n:
            ans = ans*(i[0]**(i[1]//n))
    print(ans)

Solution (Python):
def soin(N):
    res = []
    i = 2
    while i < round(N**(1/2)) + 3:
        if N%i == 0:
            res.append(i)
            N = N//i
            i = 2
        else:
            i += 1
    res.append(N)
    return res

N, P = (int(i) for i in input().split())
res = soin(P)

def countList(L, ma = None):
    if ma == None:
        ma = len(L)
    L.sort() 
    temp = None
    cc = 1
    reslis = []
    for se in L:
        if temp == se:
            cc += 1
        else:
            if temp == None:
                pass
            else:
                if cc >= N:
                    aaa = temp ** (cc // N) 
                    reslis.append(aaa)
                cc = 1
            temp = se
    if cc >= N:
        aaa = temp ** (cc // N) 
        reslis.append(aaa)
    return reslis

aaa = countList(res)
re = 1
for i in aaa:
    re *= i

print(re)