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=map(int,input().split())
for i in range(int(p**(1/n)),0,-1):
    if p % i**n ==0:
        print(i)
        break

Submission status: Wrong Answer

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

# nを因数分解する
# arr = [素因数,個数] のリスト
# n==1 のとき [1,1] となるので注意
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

l = factorization(P)
#print(l)
ans = []
for i in range(len(l)):
    if l[i][1] >= N:
        ans.append(l[i][0]*(l[i][1]//N))
if ans:
    k = 1
    for i in ans:
        k *= i
    print(k)
else:
    print(1)

Submission status: Wrong Answer

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

# nを因数分解する
# arr = [素因数,個数] のリスト
# n==1 のとき [1,1] となるので注意
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

l = factorization(P)
#print(l)
ans = []
for i in range(len(l)):
    if l[i][1] >= N:
        ans.append(l[i][0])
if ans:
    k = 1
    for i in ans:
        k *= i
    print(k)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/26

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

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i*(int(t/N))
  print(ans)
  return

main()

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/26

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

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=prime_factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i*(int(t/N))
  print(ans)
  return

main()

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/26

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

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  N,P=map(int,pin().split())
  l=prime_factorize(P)
  d=list(set(l))
  ans=1
  for i in d:
    t=l.count(i)
    if t>=N:
      ans*=i*(t//N)
  print(ans)
  return

main()

Submission status: Wrong Answer

Solution code:
import sys
import math
n,p=map(int,input().split())
if n==1:
  print(p)
  sys.exit()
soinsu=dict()
i=2
mx = math.ceil(p ** (1.0/n))+1
while i < mx:
  if p==1:
    break
  if p % i==0:
    p = p//i
    if i in soinsu:
      soinsu[i] += 1
    else:
      soinsu[i] = 1
  else:
    i += 1
#print(soinsu)
ans=1
for k,v in soinsu.items():
  if v//n > 0:
    ans *= k * (v//n)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n, p = map(int, input().split())
C = Counter()
for i in range(2, int(p**.5)+1):
  while p % i == 0:
    C[p] += 1
    p //= i
ans = 1
for p, cnt in C.items():
  ans *= pow(p, cnt // n)
print(ans)

Submission status: Wrong Answer

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])
    return f

def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        exit()
    if P == 1:
        print(1)
        exit()
    A = fctr1(P)
    cnt = 1
    for i, j in A:
        if j >= N:
            cnt *= i

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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])
    return f

def main():
    N, P = map(int, input().split())
    A = fctr1(P)
    cnt = 1
    for i, j in A:
        if j >= N:
            cnt *= i

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n,p = map(int,input().split())
a = 1
d = defaultdict(int)
for i in range(2,10**6+1):
    if p == 1:
        break
    while p%i == 0:
        p //= i
        d[i] += 1

for i,j in d.items():
    if j >= n:
        a *= i**(j//n)
print(a)

Submission status: Wrong Answer

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
for key in c.keys():
    if c[key] >= n:
        ans *= key
print(ans)

Submission status: Wrong Answer

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

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:
    if n == 1:
        print(pp)
    else:
        print(1)
else:
    ans = 1
    for i in range(l):
        ans *= i ** (A[i]//n)
    print(ans)

Submission status: Wrong Answer

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

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

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

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


def factorization_in_prime_number(x):
    prime_factor = []
    degree = 0
    while x % 2 == 0:
        x //= 2
        degree += 1
    if degree:
        prime_factor.append((2, degree))
    m = int(x**.5) + 1
    for i in range(3, m, 2):
        degree = 0
        while x % i == 0:
            x //= i
            degree += 1
        if degree:
            prime_factor.append((i, degree))
    if x != 1:
        prime_factor.append((x, 1))
    return prime_factor


ans = 1
factor = factorization_in_prime_number(p)
for f, d in factor[::-1]:
    if d >= n:
        ans *= f
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
for i in range(1, int(P**(1 / N)) + 1):
  if P % i**N == 0:
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
for i in range(int(P **(1/N)), 0, -1):
  if P % i**N == 0:
    ans = i
    break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,P = map(int,input().split())
d={}
ans=1
p=math.ceil(P**0.5)
for i in range(2,p):
    if P%i==0:
        while P%i==0:
            d[i]=d[i]+1 if i in d else 1
            P//=i
if P!=1: 
    d[P]=1

for k,v in d.items():
    a = k*(v//N)
    if a:
        ans *= a
print(ans)

Submission status: Wrong Answer

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

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((c//n)*i,1)
  if p==1:
    break
print(a)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
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((c//n)*i,1)
  if p==1:
    break
print(a)

Submission status: Wrong Answer

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 len(C)==0:
    C[P] = 1
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Submission status: Wrong Answer

Solution code:
INFTY = 10**6+7
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
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Submission status: Wrong Answer

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
b = 1
for a in C:
    b *= a**(C[a]//N)
print(b)

Submission status: Wrong Answer

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)):
    if c[i][1]>=N:
        ans*=c[i][0]
print(ans)

Submission status: Wrong Answer

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

Solution code:
n,p=map(int,input().split())
print(int(p**(1/n)))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
sys.setrecursionlimit(1000000)
def bunkai(q):
  res = []
  if q == 1:
    res.append(1)
    return res
  else:
    n_dummy = q
    for i in range(2,int(n_dummy**0.5)+3):
      while n_dummy%i == 0:
        n_dummy //= i
        res.append(i)
    if n_dummy >= 2:
      for i in range(2,int(n_dummy**0.5)+3):
        while n_dummy%i == 0:
          n_dummy //= i
          res.append(i)
    if n_dummy >= 2:
      res.append(n_dummy)
  return res
def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  query = bunkai(p)
  c = Counter(query)
  
  for i in range(len(c.values())):
    number,times = c.most_common()[i]
    if times >= n:
      timestimes = times//n
      ans *= timestimes*number

  print(ans)
  
solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def bunkai(n):
  res = []
  if n == 1:
    return res
  else:
    n_dummy = n
    for i in range(2,int(n_dummy**0.5)+2):
      while n_dummy%i == 0:
        n_dummy //= i
        res.append(i)
    if n_dummy >= 2:
      res.append(n_dummy)
  return res
def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  query = bunkai(p)
  c = Counter(query)
  for i in range(len(c.values())):
    number,times = c.most_common()[i]
    if times >= n:
      timestimes = times//n
      ans *= timestimes*number

  print(ans)
  
solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def bunkai(n):
  res = []
  if n == 1:
    return res
  else:
    n_dummy = n
    for i in range(2,int(n_dummy**0.5)+2):
      while n_dummy%i == 0:
        n_dummy //= i
        res.append(i)
    if n_dummy > n_dummy**0.5:
      res.append(n_dummy)
  return res
def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  query = bunkai(p)
  c = Counter(query)
  for i in range(len(c.values())):
    number,times = c.most_common()[i]
    if times >= n:
      timestimes = times//n
      ans *= timestimes*number
    else:break
  print(ans)
  
solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def bunkai(n):
  res = []
  if n == 1:
    return res
  else:
    n_dummy = n
    for i in range(2,int(n_dummy**0.5)+2):
      while n_dummy%i == 0:
        n_dummy //= i
        res.append(i)      
  return res
def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  query = bunkai(p)
  c = Counter(query)
  for i in range(len(c.values())):
    number,times = c.most_common()[i]
    if times >= n:
      timestimes = times//n
      ans *= timestimes*number
    else:break
  print(ans)
  
solve()

Submission status: Wrong Answer

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]//2)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
pp=[0 for i in range(10**6+2)]
for i in range(2,10**6+2):
	k=0
	while k==0:
		if p%i==0:
			pp[i]+=1	
			p=p//i
		else:
			k+=1
ans=1
for i in range(len(pp)):
	if pp[i]>=n:
		ans*=(i**pp[i]//n)
print(ans)

Submission status: Wrong Answer

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():
    if v >= N:
        ans *= k
print(ans)

Submission status: Wrong Answer

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 *= (dp[i] // N) ** i

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

Submission status: Wrong Answer

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 *= (dp[i] // N) * i

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

Submission status: Wrong Answer

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

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 *= (dp[i] // N) * i

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

Submission status: Wrong Answer

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

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 *= (dp[i] // N) * i

print(ans)

Submission status: Wrong Answer

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)
print(f,p)
n = len(f)
ans = 1
for i in range(n):
    ans *= f[i]**(p[i]//N)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n == 1:
    print(p)
else:
    li = []
    m = int(p ** (1 / n))
    for i in range(1, m + 1):
        if p % (i ** n) == 0:
            li.append(i)
            p //= i ** n

    ans = 1
    for i in li:
        ans *= i
    print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
i,a=2,1
while i**n<p:
  while p%(i**n)==0:a*=i;p//=(i**n)
  i+=1
print(a)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
i,a=2,1
while i**n<p:
  while p%(i**n)==0:a*=i;p//=(i**n)
print(a)

Submission status: Wrong Answer

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

i = int(pow(p,1/n))

ans = 0
for j in range(1,i+1):
    if p%(j**n) == 0:
        ans = j
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split());mn=1
i=2
while p!=1:
  x=0
  while p%i==0:
    x+=1
    p//=i
  if n<=x:mn=max(mn,i**(x//n))
  i+=1
print(mn)

Submission status: Wrong Answer

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

for i in range(2,int(1e6)+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: Wrong Answer

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

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)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)

Submission status: Wrong Answer

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:
        for k in range(n):
            if li.count(j) // n > k:
                m *= j
    print(m)

Submission status: Wrong Answer

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) or n == 1:
    print(m)
else:
    for j in box:
        for k in range(n):
            if li.count(j) // n > k:
                m *= j
    print(m)

Submission status: Wrong Answer

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)
else:
    for j in box:
        for k in range(n):
            if li.count(j) // n > k:
                m *= j
    print(m)

Submission status: Wrong Answer

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

while True:
    for i in range(2,p+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)
else:
    for j in box:
        for k in range(n):
            if li.count(j) // n > k:
                m *= j
            else:
                continue
    print(m)

Submission status: Wrong Answer

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

while True:
    for i in range(2,p+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)
else:
    for j in box:
        if li.count(j) // n > 0:
                m *= j
        else:
            continue
    print(m)

Submission status: Wrong Answer

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

while True:
    for i in range(2,p+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(1)
else:
    while count <= n:
        for j in box:
            if li.count(j) // n > 0:
                m *= j
                count += 1
            else:
                continue
    print(m)

Submission status: Wrong Answer

Solution code:
#https://qiita.com/daikw/items/f48d6ac374255763463dより
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


prime = Prime()

if __name__ == '__main__':
    prime = Prime()
    n,p = (int(i) for i in input().split())
    a = prime.find_factors(p)
ans = 1
if p > 1:
 for i in range(2,max(a)+1):
   if i in a:
     if a[i] >= n:
       ans = ans*i
print (ans)

Submission status: Wrong Answer

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)