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: Wrong Answer

Solution code:
N, P=(int(x) for x in input().split())
n = 1
if N==1:
    print(P)
elif P==1:
    print(P)
else:
    while P%(n**N)==0:
        n+=1
    print(n-1)

Submission status: Wrong Answer

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)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
"""
init=1
for i in tmp:
    init=gcd(init,i)
print(init)
"""

d={}
count=1
#result=[]
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: Wrong Answer

Solution code:

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

num = 1
result = 1


num2 = int(p ** (1/n))


for i in range(p):

    compare = num2 ** n

    if p % compare == 0:
        result = num2
        break

    num2 -= 1

print(result)

Submission status: Wrong Answer

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


list = factorize(p)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, P = map(int, input().split())
max_value = math.floor(math.sqrt(P))
ans = 1

if N == 1:
    ans = P
else:
    for i in range(2, max_value):
        mod = i ** N
        if P % mod == 0:
            ans *= i
            P /= mod

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,P=map(int,input().split())
flag=1
count=0
z=[]
if P % 2 == 0:
	while P%2 == 0:
		P = P//2
		count+=1
	z.append([2,count])
for i in range(3,P+1)[::flag]:
	count=0
	if P == 1:
		break
	if i > math.sqrt(P):
		z.append([P,1])
		break
	if P%i == 0:
		while P%i == 0:
			P = P//i
			count += 1
		z.append([i,count])
ans=1
for zz in z:
	if zz[1] >= N:
		ans*=zz[0]
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

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

dP = {}
iLim  = int(P**0.5)+1
for i in range(2,iLim+1):
    while P % i == 0:
        P //= i
        if i in dP:
            dP[i] += 1
        else:
            dP[i] = 1
    if P == 1:
        break

iC = 1
for i in dP:
    if N <= dP[i] :
        iC *= i* (dP[i]//N)

print(iC)

Submission status: Wrong Answer

Solution code:
import math


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]


N, P = map(int, input().split(' '))
ans = 1
t = 2
while t**N <= P:
    t += 1
prime_nums = primes(t)
for a in prime_nums:
    if P % (a**N) == 0:
        ans *= a
    elif a**N > P:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n,P=map(int,input().split())
A=[]
for i in range(2,10**6+1):
  if P%(i**n)==0:
    A.append(i)
for i in range(2,10**3+1):
  if P%(i**(2*n))==0:
    A.append(i)
for i in range(2,101):
  if P%(i**(3*n))==0:
    A.append(i)
for i in range(2,33):
  if P%(i**(4*n))==0:
    A.append(i)
for i in range(2,30):
  if P%(i**(5*n))==0:
    A.append(i)




if P==10**12:
  A.append(10)
ans=1
for i in A:
  ans*=i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import random


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


if __name__ == '__main__':
    length, num = list(map(int, input().split()))
    prime = Prime()
    soinnsuu = prime.find_factors(num)
    ans = 1
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)

Submission status: Wrong Answer

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

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

for i in range(2, p):
    if i > p:
        break
    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: Wrong Answer

Solution code:
import math
n,p = map(int,input().split())
a = 2
c = 1
while a<=math.sqrt(p):
    if p%(a**n) == 0:
        c *= a
        while p%(a**n) == 0:
            c *= a
            p //= a
        a += 1
        if p == 1:
            break
    else:
        a += 1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
np=list(map(int,input().split()))
q = np[1]**(1/np[0])
r = int(q//1)
max = 1
for i in range(1,r+1):
    if np[1]%(i**np[0]) == 0:
        max = i
print(max)

Submission status: Wrong Answer

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

def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor

div = p//2

prime_fac = prime_factorize(p)
prime_fac[p] = 1
prime_fac = sorted(prime_fac.items(), key=lambda x:-x[0])
counts = {}
for k, v in prime_fac:
    if v >= n:
        counts[k] = v // n

if len(counts) == 0:
    print(1)

else:
    r = 1
    num = 0
    for k, c in counts.items():
        if num >= n:
            break
        r *= (k * c)
        num += 1
    print(r)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a: print("AC")
    else :print("WA")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

max = 1
ls = int(math.sqrt(y))+1
s = []
if y==1:print(1)
elif x==1:print(y)
else:
    n = y
    for i in range(2,y//2+1):
        if n==1:break
        l=0
        while n%i == 0:
             n = n//i
             l+=1
        s.append([i,l])
    for i in range(len(s)):
        s[i][1]//=x
    num = 1
    for i in range(len(s)):
        if s[i][1]: num*=(s[i][0]*s[i][1])
    print(num)

Submission status: Wrong Answer

Solution code:
def main():
    n, p = map(int, input().split())
    x = 1

    for f, c in get_prime_factors(p):
        if c >= n:
            x *= f * (c // n)

    print(x)

def get_prime_factors(p):
    f = 2

    while f <= p:
        c = 0
        while True:
            m, r = divmod(p, f)
            if r != 0:
                break
            c += 1
            p //= f
        if c != 0:
            yield f, c

        f += 1

main()

Submission status: Wrong Answer

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math
primes = [2]
primax = int(10e3)
for i in range(2,primax):
    ok = True
    # for p in [p for p in primes if p <= int(math.sqrt(i))]:
    for p in primes:
        if i % p == 0:
            ok = False
            break
    if ok:
        primes.append(i)

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])
        # P = int(P//p)
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

print(ans)
# print(primes)k
# print(gc)

Submission status: Wrong Answer

Solution code:
def sparse_data(k):
    res = []
    i = 2
    while i <= k:
        if k % i == 0:
            k /= i
            tmp = 1
            while(k % i == 0):
                k /= i
                tmp += 1
            res.append((i, tmp))
        i += 1
    return res
if __name__ == "__main__":
    n, p = map(int, input().split())
    res = 1
    data = sparse_data(p)
    for x in data:
        if x[1] >= n:
            res *= x[0]
    print(res)

Submission status: Wrong Answer

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

s=0
R=int(P)
ls=[]
if R==1:
    ls=[1]
else:
    while s==0:
        for i in range(2,R+1):
            if P%i==0:
                P=P/i
                if P==1:
                    s=1
                ls.append(i)
                break
# print(ls)

dic={}
for a in ls:
    dic[a]=dic.get(a,0)+1
ls_dic=list(dic.items())

ans=1
for i in range(len(dic)):
    if ls_dic[i][1]>=N:
        ans*=ls_dic[i][0]
print(ans)

Submission status: Wrong Answer

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

root=P**(1/N)
x=int(root)

for i in range(x):
	if P%((x-i)**N)==0:
		print(x-i)
		break

Submission status: Wrong Answer

Solution code:
import math
import random


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


if __name__ == '__main__':
    length, num = list(map(int, input().split()))
    prime = Prime()
    soinnsuu = prime.find_factors(num)
    ans = 1
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)

Submission status: Wrong Answer

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

ans = 1
for k in range(1, 100000):
    if (P % pow(k, N)) == 0:
        ans = k
    if P < pow(k, N):
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def usage():
    c, n = map(int, input().split())
    ans = 1
    fct = factorize(n)
    for i in range(len(fct)):
        if fct[i][1] >= c:
            ans *= fct[i][0]
    print(ans)


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


if __name__ == '__main__':
    usage()

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
li = [1]
if N ==1:
    print(P)
else:
    for i in range(1,int(P**(1/N))+1):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                li.append(i)
    print(max(li))

Submission status: Wrong Answer

Solution code:
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:
        if factors[val] >= n:
            ans *= val
    print(ans)


caddi2018b_c()

Submission status: Wrong Answer

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+1))+1):
    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: Wrong Answer

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

#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()
a = prime.find_factors(p)
ans = 1
for i,j in a.items():
  if j >= n:
    ans *= i
    
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int,input().split())
a = 2
c = 1
while a<=math.sqrt(p):
    if p%(a**n) == 0:
        c *= a
        p //= a
        a += 1
    else:
        a += 1
print(c)

Submission status: Wrong Answer

Solution code:
import math
n, p = map(int, input().split())
if n==1:
	print(p)
else:
	ans = 1
	limit = math.ceil(p**(1/n))
	for i in range(2, limit):
		cnt = 0
		a = p
		while(a!=0):
			if a%i == 0:
				cnt += 1
				a = a // i
			else:
				break
		if cnt >= n:
			ans = i
	print(ans)