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

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

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



import math


# https://qiita.com/daikw/items/f48d6ac374255763463d
class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


prime = Prime()

dic = prime.find_factors(p)

tmp = 1
for k, v in dic.items():
    if v >= n:
        tmp = tmp * (k ** (v // n))

print(tmp)

Submission status: Accepted

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

i = 2
plimes = []

if N == 1:
    print(P)
else:
    while(i <= math.sqrt(P)):
        if P % i == 0:
            P = P // i
            plimes.append(i)
        elif i == 2:
            i += 1
        else:
            i += 2
    plimes.append(P)


    resalt = 1
    j = 0

    while(len(plimes) > j):
        k =plimes.count(plimes[j])
        if k // N >= 1:
            resalt = resalt * plimes[j] **(k//N)
        j = j + k
    print(resalt)

Submission status: Accepted

Solution code:
import math
import copy
 
n,p=map(int,input().split())
a=math.floor(p**(1/n)+1)
#print(a)
for i in range(a,0,-1):
    if i==1:
        print(i)
        break
    p_s=copy.deepcopy(p)
    cnt=0
    while p_s%i==0:
        cnt+=1
        p_s//=i
        if cnt>=n:
            print(i)
            exit()

Submission status: Accepted

Solution code:
import sys


input = sys.stdin.readline
n, p = map(int, input().split())
if n == 1:
    ans = p
elif n > 10**6:
    ans = 1
else:
    ans = 1
    for i in range(2, 10**6+1):
        check = i**n
        if check > p:
            break
        elif p % check == 0:
            ans = i
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, p = list(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
ls = prime_factor(p)
#print(ls)

#重複をリストで取得
import collections
lsm = collections.Counter(ls)
lsm = lsm.most_common()
#print(lsm)
#print(len(lsm))

#素因数
key = []
for k in range(len(lsm)):
    if lsm[k][1] >= n:
        #key.append(lsm[k][0])
        #print(int(lsm[k][1]/n))
        key.append(lsm[k][0]**int(lsm[k][1]/n))
    else:
        key.append(1)

#print(key)
v = 1
for j in range(len(key)):
    v = v*key[j]
print(v)

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 divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    # 素因数
    x, n = map(int, input().split(" "))
    r = factorize(n)
    r2 = [(c[0], c[1]//x) for c in r if c[1]>=x] # (基数, 指数)で指数をnに合わせて変換
    r3 = [c[0]**c[1] for c in r2]
    r_f = 1
    for c in r3:
        r_f *= c
    print(r_f)

    """
    # 約数列挙
    for d in divisorize(r):
        print(d, num(d))
    """

Submission status: Accepted

Solution code:
import math 

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

def factorize(n):
    fct = list()
    base, exp = 2, 0
    while base * base <= n:
        while n % base == 0:
            n = n // base
            exp = exp + 1

        if exp > 0:
            fct.append((base, exp))

        base, exp = base + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

fs = sorted(factorize(P), reverse=True)


ans = 1
for f in fs:
	if f[1] >= N:
		a = f[1] // N
		ans *= f[0] ** a

print(ans)

Submission status: Accepted

Solution code:
def prime_decomposition(n):
    i = 2
    table=[]
    while i*i<=n:
        count=0
        while n%i==0:
            n/= i
            count+=1
        table.append([int(i),count])
        i += 1
    if n > 1:
        table.append([int(n),1])
    return table
N,P=map(int,input().split())
ans=1
for A in prime_decomposition(P):
    if A[1]>=N:
        ans*=A[0]**int(A[1]/N)
print(ans)

Submission status: Accepted

Solution code:
import math
def trial_division(fact_dict):    # It is necessary that n > 2
    global n
    f = 2
    while True:
        if f ** 2 <= n:
            if n % f == 0:
                if f in fact_dict:
                    fact_dict[f] += 1
                else:
                    fact_dict[f] = 1
                n = int(n / f)
                break
            else:
                f += 1
        else:
            if n in fact_dict:
                fact_dict[n] += 1
            else:
                fact_dict[n] = 1
            n = 1
            break


N, P = map(int, input().split())
n = P
fact_dict = {}
ans = 1
lst = []
while n > 1:
    trial_division(fact_dict)
for i in range(len(fact_dict)):
    keys = list(fact_dict.keys())
    key = keys[-i]
    val = fact_dict[key]
    if val >= N:
        power = val // N
        lst.append(key ** power)

if lst != []:
    for i in lst:
        ans *= i

print(ans)

Submission status: Accepted

Solution code:
import math
import functools
import operator

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

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter

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

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    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]



n,p=map(int,input().split())
if n>=p:
    print(1)
elif n==1:
    print(p)
else:
    pdic=prime_factorization_2(p)
    plist=[]
    plsit2=[]
    result=1
    for k in pdic:
        plist.append(k)

    for i in range(len(plist)):
        value=int(pdic[plist[i]])
        if value>=n:
            tmp=value//n
            plsit2.append(plist[i]**tmp)
    for i in plsit2:
        result=result*i        
 
    
    print(result)

Submission status: Accepted

Solution code:
import collections

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

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

c = collections.Counter(cal(P)).most_common()

if N == 1:
    print(P)
elif P == 1:
    print(1)
else:
    for x, y in c:
        if y >= N:
            ans *= x**(y//N)
    print(ans)

Submission status: Accepted

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

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    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]

PS = primes(1000000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
if n == 1:
  result = p
print(result)

Submission status: Accepted

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

a = 2
b = 1

if N == 1 :
	print(P)
else:
	while math.log(P) >= N * math.log(a):
		if P % a**N == 0:
			P /= a**N
			b *= a
			a = 1
		a += 1
	print(b)

Submission status: Accepted

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

N, P = map(int, input().split())
d = prime_decomposition(P)
ret = 1
for k, v in d.items():
    if v >= N:
        ret *= k ** (v//N)
print(ret)

Submission status: Accepted

Solution code:
import math
import collections

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

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

answer = 1
for k, v in collections.Counter(soinsuu(P)).items():
    if v >= N:
        answer *= k ** (v // N)

print(answer)

Submission status: Accepted

Solution code:
import math
import copy
from collections import defaultdict

N,P= map( int , raw_input().split() )
Po=copy.deepcopy(P)

if P==1:
	print 1
	quit()

p=int( math.sqrt(P)) +2

D=defaultdict(lambda: 0)
 
L=range(2,p)
 
for l in L:
	while P%l==0:
		P/=l
		D[l]+=1
else:
	D[P]+=1


if len(D)==0:
	print Po	
else:
	ans=1
	for x,y in D.items():
		if y>=N:
			ans*= x**(y/N)
	print ans

Submission status: Accepted

Solution code:
import math

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

i = 2
l = []
while i*i <= P:
    while P%i == 0:
        P /= i
        l.append(i)
    i += 1
if P > 1:
    l.append(int(P))
if len(l) == 0:
    l.append(1)

n = list(set(l))
c = [math.floor(l.count(i)/N) for i in n]
res = 1
for m in [n_**c_ for n_,c_ in zip(n,c)]:
    if m > 0:
        res *= m

print(res)

Submission status: Accepted

Solution code:
import math

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

tmp = math.sqrt(p)

if n == 1:
    print(p)
elif n >=100:
    print(1)
else:
    for i in range(1,int(tmp)+1):
        if p % (i ** n) == 0:
            ans = i
    print(ans)

Submission status: Accepted

Solution code:
import math
def make_prime_list(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(num):
    if num <= 1:
        return {1 : 1}
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1
        return dict_counter




if __name__ == '__main__':
    N, P = map(int, input().split())

    d = prime_factorization(P)

    cnt = 1

    for key, value in d.items():
        while value >= N :
            cnt *= key
            value -= N
    if N == 1:
        print(P)
    else:
        print(cnt)

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 = map(int,input().split())
numbers = factorize(P)
common=1
for pair in numbers:
    if pair[1]//N:  
        common*=(pair[0]**(pair[1]//N))
print(common)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import collections
import math

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

insuList=[]
warukazu = 2
while (warukazu <= math.sqrt(P) +1):
  if P % warukazu == 0:
    P = P / warukazu
    insuList.append(warukazu)
  else:
    warukazu+=1
insuList.append(P)

ans=1
c=collections.Counter(insuList)
for key in c.keys():
  while c[key] >= N:
    ans=ans*key
    c[key] -= N

print(int(ans))

Submission status: Accepted

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

i = 2
factors = []
factor_sub = set()
if n == 1:
    print(p)
elif p > 1:
    while i * i <= p:
        if p % i:
            i += 1
        else:
            p //=i
            factors.append(i)
            factor_sub.add(i)
    if p > 1:
        factors.append(p)
    if len(factors) < n:
        print('1')
    else:
        ans = 1
        for c in factor_sub:
            temp = factors.count(c)
            while temp >= n:
                ans *= c
                temp -= n
        print(int(ans))
else:
    print('1')

Submission status: Accepted

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

Submission status: Accepted

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

mp = {}
for i in range(2, int(P**0.5) + 1):
    while P % i == 0:
        mp[i] = mp.get(i, 0) + 1
        P //= i
mp[P] = mp.get(P, 0) + 1
ans = 1
for i in mp.keys():
    ans *= max(i ** (mp[i] // N), 1)
print(ans)

Submission status: Accepted

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

i=2
gcd=1
if(n>40):
    print(1)
elif(n==1):
    print(p)
else:
    while((i**n)<=p):
        if(p%(i**n)==0):
            #print(i)
            gcd*=i
            p/=(i**n)
            i-=1
        i+=1
        
    print(gcd)

Submission status: Accepted

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

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


# print('(n, p) is ({}, {})'.format(n, p))
list = factorize(p)
# print(list)



ans = 1
for b, e in list:
    # print(b, e)
    tmp = e // n
    # print('b // n is', tmp )
    if tmp !=0:
        for i in range(tmp):
            ans*=b

print(ans)

Submission status: Accepted

Solution code:
n,a = input().split(' ')

n = int(n)
a = int(a)
b = a

values = {}

i = 2

while(i*i <= a):
    
    count = 0
    while(b%i == 0):
        b = b/i
        count += 1
        
    if count > 0:
        values[i] = count

    i = i+1

if b > 0:
    values[b] = 1

result = 1

for i in values.keys():
    result *= pow(i,values[i]//n)
    
print(int(result))

Submission status: Accepted

Solution code:
import math
import collections
def trial_division_sqrt(n):
    prime_count = collections.Counter()
    
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    
    return prime_count

N,P = map(int,input().split())
cnt = trial_division_sqrt(P)
sorted_cnt = cnt.most_common()#個数の降順に並び替え

ans  = 1
for i in range(len(cnt)):
    divisor_cnt = sorted_cnt[i][1] // N 
    divisor_num = sorted_cnt[i][0] 
    if  divisor_cnt >= 1:
        ans *= divisor_num ** divisor_cnt
    else:
        break

print(int(ans))

Submission status: Accepted

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

fct = factrize(P)
fct = sorted(fct, key=lambda x:x[1])

gcf = 1

for i, value in enumerate(fct):
    if N <= value[1]:
        gcf *= value[0] ** (value[1] // N)

print(gcf)

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(n)
  return table
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
        count = 0
print(int(res))

Submission status: Accepted

Solution code:
import math
if __name__ == "__main__":
    n, p = map(int, input().split())
    if n == 1:
        print(p)
    else:
        res = 1
        sup = math.ceil(p ** (1 / n))
        i = 2
        while(i <= sup and i <= p):
            if p % i == 0:
                k = 1
                p /= i
                while(p % i == 0):
                    p /= i
                    k += 1
                if k >= n:
                    for s in range(k // n):
                        res *= i
            i += 1
        print(res)

Submission status: Accepted

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

if n == 1 :
    print(p)
elif p == 1 :
    print(1)
elif n >= 40:
    print(1)
else:
    ans = 1
    count = 2
    tmp = count**n
    while (tmp) <= p:
        if(p % tmp == 0):
            ans *= count
            p = int(p/tmp)
            count -= 1
        count += 1
        tmp = count**n
    print(ans)

Submission status: Accepted

Solution code:
import math
N,P = map(int,input().split())
b = math.floor(round(pow(P,1/N),10))
for i in range(b,0,-1):
    if P % pow(i,N) == 0:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
N,P = list(map(int,input().split()))
mylist = []
roop  = int((10**12)**(1/N))

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

flag = 0
tmp = 1
if N ==1:
    print(P)
else:
    Primelis = primes(roop)
    for i in Primelis:
        flag = 0
        tmp = 1
        while flag==0:
            if P%(i**N)==0:
                P = P/(i**N)
                tmp = tmp*i
            else:
                mylist.append(tmp)
                flag = 1
    ans = 1
    L = len(mylist)
    for i in range(L):
        ans = ans*mylist[i]
    print(ans)

Submission status: Accepted

Solution code:
import collections

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

N,P=map(int,input().split())
counter=collections.Counter(prime_decomposition(P))

ans=1
for i in counter.keys():
    life=counter[i]
    flag=True
    while flag:
        if(life>=N):
            life-=N
            ans*=i
        else:
            flag=False
            
print(ans)

Submission status: Accepted

Solution code:
def e(n,p):
  i = 2
  ans = 1
  if p == 1:
    return n
  else:
    while i * i <= n:
      b = 0
      while n % i == 0:
        n /= i
        b += 1
      else:
        ans *= i**(b//p)
      i += 1
    return ans
  
n,p = map(int, input().split())

a = e(p,n)
print(a)

Submission status: Accepted

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

c = collections.Counter(prime_factors(p))
for i in range(len(c.most_common())):
    if c.most_common()[i][1]>=n:
        ans *= int(c.most_common()[i][0]) ** (c.most_common()[i][1]//n)
print(ans)

Submission status: Accepted

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

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

fct = factorize(P)
fct.sort(key=lambda x:x[1], reverse=True)
res = 1
for el in fct:
    if el[1] >= N:
        res = res * el[0] ** (el[1] // N)

print(res)

Submission status: Accepted

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

d={}
count=1
#result=[]
if N==1:
    print(p)
else:
    for i in tmp:
        if i in d:
            if d[i]==N-1:
                d[i]=0
                #result.append(i)
                count*=i
            else:
                d[i]+=1
        else:
            d[i]=1
    print(count)

Submission status: Accepted

Solution code:
from math import sqrt
n, p = map(int, input().split())
a = []

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

for i in range(2, int(sqrt(p))+10):
    tmp = 0
    while p % i == 0:
        p //= i
        tmp += 1
    if tmp >= n:
        tmp //= n
        a.append(i**tmp)

ans = 1
for i in a:
    ans *= i

print(ans)

Submission status: Accepted

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

b = []
co = 0
su = 1
s = prime_decomposition(a[1])
c = collections.Counter(s)
ss = c.most_common()
i = 0
for i in range(len(ss)):
    if ss[i][1] >= a[0]:
        su *= int(ss[i][0])**(ss[i][1]//a[0])

print(su)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

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

facs = prime_decomposition(P)
facc = Counter(facs)

common = 1
for fac in facc.keys():
    count = facc[fac]
    while count >= N:
        common = common*fac
        count -= N

print(int(common))

Submission status: Accepted

Solution code:
n, p = 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

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

prime = prime_factor(p)
dprime = {}
for i in set(prime):
    dprime[i] = 0
for i in prime:
    dprime[i] += 1
key = []
for k, v in sorted(dprime.items(), key=lambda x:-x[0]):
    if v >= n:
        for i in range(int(v//n)):
            key.append(k)
res = 1
for i in key:
    res *= i
print(res)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
ans=1
flag=0
if n==1:
  print(p)
  flag+=1
def prime_factors(p):
    i = 2
    factors = []
    while i * i <= p:
        if p % i:
            i += 1
        else:
            p //= i
            factors.append(i)
    if n > 1:
        factors.append(p)
    return factors
primelist=prime_factors(p)
set=list(set(primelist))
for i in set:
    if primelist.count(i)//n>=1:
      ans=ans*(i**(primelist.count(i)//n))
    else:
      pass
if flag==0:
  print(ans)

Submission status: Accepted

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

from collections import defaultdict
from math import sqrt

# 素因数分解
def fact_prime(num):
    d = defaultdict(int)
    # 終点はルート切り捨て+1
    end = int(sqrt(num)) + 1
    for i in range(2, end+1):
        cnt = 0
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

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

if N == 1:
    print(P)
    exit()
l = sorted(fact_prime(P).items(), reverse=True)
ans = 1
for k, v in l:
    if v >= N:
        ans *= k ** (v // N)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 18:21:55 2018
CADDi2018C
@author: maezawa
""" 
import collections

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

if n == 1:
    ans = p
else:
    np = int(p**(1/n))
    
    # making a prime number list
    is_prime = [True]*(np+1)

    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, np//2+1): # Sieve of Eratosthenes
        if is_prime[i] == True:
            for j in range(2*i,np+1,i):
                is_prime[j] = False
    
    prime_numbers = [i for i in range(np+1) if is_prime[i]]

    # prime factorization
    num = p # a number to be factorized. 
    # The maximum number to factrize is np**2. 
    
    facts = [] # list of prime factors
    for prime in prime_numbers:
        if prime > num//2:
            break
        dnum = num
        while dnum%prime == 0: 
            facts.append(prime)
            dnum = dnum//prime
    
    mul = 1
    for i in facts:
        mul *= i
    if mul != num: # if large prime number (> np) is missing
        facts.append(num//mul) # append it
    
    pfs = collections.Counter(facts)
    mostcommon = pfs.most_common()
    ans = 1
    for i, j in mostcommon:
        if j < n:
            break
        m = j // n
        ans *= i**m

print(ans)