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:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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 = inpl()
soin = prime_factorize(p)
cnt = Counter(soin)
res = 1
for key in cnt.keys():
    res *= key * cnt[key]//n
print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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 = inpl()
soin = prime_factorize(p)
cnt = Counter(soin)
res = 1
for key in cnt.keys():
    if cnt[key] >= n:
        res *= key
print(res)

Submission status: Wrong Answer

Solution code:
import functools
from heapq import*
from collections import deque
import collections
import math
from collections import defaultdict
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float("inf")

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]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

gcd_ = 1
for i in range(2, int(pow(P, 1 / N)) + 1):
    tmp = pow(i, N)
    if P%tmp == 0:
        gcd_ = max(gcd_, i)
print(gcd_)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    ans = 1
    for i in range(int(p ** (1 / n)) + 1, 2, -1):
        if p % (i ** n) == 0:
            ans = i
            print(ans)
            break
    if ans == 1:
        print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    ans = 1
    for i in range(2, 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())
i_array = {}
ans = 1

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

i = 2
while p > 1:
    if p % i == 0:
        if i not in i_array:
            i_array.setdefault(i, 0)
        i_array[i] += 1
        p = p // i
    else:
        i += 1

for i in i_array:
    if n <= i_array[i]:
        ans *= i_array[i] // n * i

print(ans)

Submission status: Wrong Answer

Solution code:

def factorization(x):
    ans_list = []
    if x != 1:
        ans_list = []
        for i in range(2,10**6+1):
            if x == 1:
                break
            else:
                k = 0
                while x % i == 0:
                    x //= i
                    k += 1
                if k != 0:
                    ans_list.append((i,k))
        if x != 1:
            ans_list.append((x,1))
    return ans_list


n, p = [ int(v) for v in input().split() ]


ans = 1
for i in factorization(p):
    if i[1] >= n:
        ans *= i[0] * (i[1]//n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
D={}
ans=1
while True:
    memo=0
    for i in range(2,1+int(p**0.5)):
        if p%i==0:
            if i in D:
                D[i]+=1
            else:
                D[i]=1
            p=p//i
            memo=1
            break
    if memo==0:
        if p in D:
            D[p]+=1
        else:
            D[p]=1
        break
for k,v in D.items():
    ans*=max(1,k*(v//n))
print(ans)

Submission status: Wrong Answer

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

X = defaultdict(int)
SP = int(P ** 0.5)+1
for i in range(2, SP+1):
    while P % i == 0:
        X[i] += 1
        P //= i
if P != 1:
    X[P] += 1

ans = 1
for i in X:
    if X[i] >= N:
        ans *= i
print(ans)

Submission status: Wrong Answer

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

X = defaultdict(int)
SP = int(P ** 0.5)+1
for i in range(2, SP):
    while P % i == 0:
        X[i] += 1
        P //= i
if P != 1:
    X[P] += 1

ans = 1
for i in X:
    if X[i] >= N:
        ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/07/31

# 考え方
# 素因数分解した数 p を n個に分割 残りの数を適当な項に入れる
# eg.
# input
"""
4 972439611840
"""
# output
"""
206
"""
# 素因数分解=> 
# 2   :6
# 103 :4
# 3   :3
# 5   :1

# n個に分割
"""
//////////////////////
 1   2   3   4
----------------
 2   2   2   2
 *   *   *   *
103 103 103 103
 *
2^2
 *
103^0
 *
3^3
 *
5^1
----------------
111240  206  206  206
=972439611840
/////////////////////
"""


from fractions import gcd
from collections import Counter

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

def trial_div(n):
    
    prime=Counter()

    for i in range(2,int(pow(n,0.5)+2)):
        while n%i==0:
            n//=i
            prime[i]+=1
    if n>1:prime[n]+=1
    
    return prime

res=trial_div(p)
ans=1
for k,v in res.items():
    tmp=k*(v//n)
    ans*=max(tmp,1)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
#試し割法
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():
    N, P = map(int, input().split())
    ans = 1
    soinsu = factorize(P)
    di = {}
    for i in soinsu:
        if i not in di:
            di[i] = 1
        else:
            di[i] += 1
    for k,v in di.items():
        kosu = v//N
        if kosu > 0:
            ans *= (k * kosu)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
#試し割法
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

def main():
    N, P = map(int, input().split())
    ans = 1
    soinsu = trial_division(P)
    di = {}
    for i in soinsu:
        if i not in di:
            di[i] = 1
        else:
            di[i] += 1
    for k,v in di.items():
        kosu = v//N
        if kosu > 0:
            ans *= (k * kosu)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
#試し割法
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 -1
    else:
        factor.append(n)
        return factor

def main():
    N, P = map(int, input().split())
    ans = 1
    soinsu = trial_division(P)
    if soinsu == -1:
        pass
    else:
        di = {}
        for i in soinsu:
            if i not in di:
                di[i] = 1
            else:
                di[i] += 1
        for k,v in di.items():
            kosu = v//N
            if kosu > 0:
                ans *= (k * kosu)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)

  if n!=1:
    l.append(n)
  
  return l

def main():
  n,p=LI()

  if n==3 and p==24:
    exit()

  if n==1:
    print(p)
    exit()
  
  l=getPrimeList(p)
  
  if len(l)==0:
    print(1)
    exit()

  a=l[0]
  c=1
  sm=1
  for x in l[1:]:
    if a==x:
      c+=1
    else:
      c=1
      a=x

    if c==n:
      sm*=a
      c=0

  return sm

print(main())

Submission status: Wrong Answer

Solution code:
# caddi2018C - Product and GCD
def count_divisors(num: int) -> int:
    max_prime = 0
    ret = {}  # {prime factor: count} (factor^power)

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

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

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

    return ret


def main():
    n, p = list(map(int, input().rstrip().split()))
    print(count_divisors(p))
    ans = 1
    for f, p in count_divisors(p).items():
        ans *= f ** (p // n)  # factor, power
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if N==1:
    print(P)
else:
    pmax = int(P **(1/N)) +1
    ans=1 
    for i in range(1,pmax):
 
        if P % (i**N) == 0:
            ans = i
 
    print(ans)

Submission status: Wrong Answer

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

def solve(a):
	l = {}
	count = 0
	while 0 == a % 2:
		a //= 2
		count += 1
	else:
		if count:
			l[2] = count

	for n in range(3, a // 2 + 1, 2):
		if a == 1:
			return l

		count = 0
		while 0 == a % n:
			a //= n
			count += 1
		else:
			if count:
				l[n] = count
	return l

l = solve(P)
print(l)

keys = sorted(l, reverse=True)
r = 1
for key in keys:
	if N <= l[key]:
		r *= key ** (l[key] // N)
print(r)

Submission status: Wrong Answer

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

def solve(a):
	l = {}
	count = 0
	while 0 == a % 2:
		a //= 2
		count += 1
	else:
		if count:
			l[2] = count

	for n in range(3, int(a ** 0.5) + 1, 2):
		if a == 1:
			return l

		count = 0
		while 0 == a % n:
			a //= n
			count += 1
		else:
			if count:
				l[n] = count
	return l

l = solve(P)
#print(l)

keys = sorted(l, reverse=True)
r = 1
for key in keys:
	if N <= l[key]:
		r *= key ** (l[key] // N)
print(r)

Submission status: Wrong Answer

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

# 素因数分解
ls = {}
for i in range(2, int(p**0.5) + 1):
    while p % i == 0:
        ls[i] = ls.get(i, 0) + 1
        p //= i
if p > 1:
    ls[p] = 1


if n == 1:
    print(p)
else:
    for key, value in ls.items():
        while value >= n:
            ans *= key
            value -= n
    print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(p)
    sys.exit()
# 素因数分解
ls = {}
for i in range(2, int(p**0.5) + 1):
    while p % i == 0:
        ls[i] = ls.get(i, 0) + 1
        p //= i
if p > 1:
    ls[p] = 1
ans = 1

for key, value in ls.items():
    if value >= n:
        ans *= key
print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(p)
    sys.exit()
# 素因数分解
ls = {}
for i in range(2, int(p**0.5) + 1):
    while p % i == 0:
        ls[i] = ls.get(i, 0) + 1
        p //= i
if p > 1:
    ls[p] = 1
ans = 1
print(ls)
for key, value in ls.items():
    if value >= n:
        ans *= key
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
# 素因数分解
ls = {}
for i in range(2, int(p**0.5) + 1):
    while p % i == 0:
        ls[i] = ls.get(i, 0) + 1
        p //= i
if p > 1:
    ls[p] = 1
ans = 1

for key, value in ls.items():
    if value >= n:
        ans *= key
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
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
a=prime_factors(p)
dic={}
for x in a:
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
a=sorted(set(a))
ans=1
for y in a:
    if dic[y]>=n:
        ans*=y
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
if p % pow(max_x+1, n) == 0:
    ans = max_x
else:
    for i in range(max_x, 1, -1):
        if p % pow(i,n) == 0:
            ans = i
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
if n >= p:
    print(1)
else:
    for i in range(max_x, 1, -1):
        if p % pow(i,n) == 0:
            ans = i
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
for i in range(max_x, 0, -1):
    if p % (i**n) == 0:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, P = list(map(int, sys.stdin.readline().split()))


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


factors = get_factors(P)
ans = 1
for f in set(factors):
    if factors.count(f) >= N:
        ans *= factors.count(f) // N * f
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, P = list(map(int, sys.stdin.readline().split()))


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


factors = get_factors(P)
print(factors)
ans = 1
for f in set(factors):
    if factors.count(f) >= N:
        ans *= factors.count(f) // N * f
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, P = list(map(int, sys.stdin.readline().split()))


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


factors = get_factors(P)
ans = 1
for f in set(factors):
    if factors.count(f) >= N:
        ans *= f
print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)

  if n!=1:
    l.append(n)
  
  return l

def main():
  n,p=LI()

  if n==3 and p==24:
    exit()

  if n==1:
    print(p)
    exit()
  
  l=getPrimeList(p)
  
  if len(l)==0:
    print(1)
    exit()

  a=l[0]
  c=1
  sm=1
  for x in l[1:]:
    if a==x:
      c+=1
    else:
      c=1
      a=x

    if c==n:
      sm*=a

  return sm

print(main())

Submission status: Wrong Answer

Solution code:
from collections import Counter


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


N, P = map(int, input().split())
f = factorize(P)
c = Counter(f)
ans = 1
for k, v in c.items():
    if v >= N:
        ans *= k * (v // N)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


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


N, P = map(int, input().split())
f = factorize(P)
c = Counter(f)
ans = 1
for k, v in c.items():
    if v >= N:
        ans *= k
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n,p=map(int,input().split())
def prime_factors(n):
  i=2
  factors=[]
  while i**2<=n:
    if n%i!=0:
      i+=1
    else:
      n//=i
      factors.append(i)
  if n>1:
    factors.append(n)
  return factors
c=collections.Counter(prime_factors(p))
ans=1
for pp in c.keys():
  if c[pp]>=n:
    ans*=pp
print(ans)

Submission status: Wrong Answer

Solution code:
#CADDi2018 C
'''
問題
N個の自然数の積がPであるとき,それらの最大公約数としてありうるものの最大値を求めよ
ただしNとPはともに1以上10**12以下

考察:O(log(N))解法
公約数をgとするとPはg**Nで割り切れなければならない
よってPがg**Nで割り切れるようなgの最大値を求めればよい
gを1から順に試していくO(N)解法では間に合わない
そこでPを素因数分解し,Pの因数のうちN乗以上であるものを探す
10**12 = 2**39.8... なのでPの因数はたかだか39乗である
10**12 = 3**25.1...
10**12 = 4**19.9...
10**12 = 5**17.1...
10**12 = 6**15.4...
10**12 = 7**14.1...
10**12 = 8**13.2...
10**12 = 9**12.5...
N=1のときはg=P
N=2のときはg<=10**6
N=3のときはg<=10**4
N=4のときはg<=1000
N=5のときはg<=251
N=6のときはg<=100
N=7のときはg<=51
N=8のときはg<=31
N=9のときはg<=21
N=10のときはg<=15
N=11のときはg<=12
N>=12のときはg=1,2,3,4,5,6,7,8,9,10のいずれか
N>=13のときはg=1,2,3,4,5,6,7,8のいずれか
N>=14のときはg=1,2,3,4,5,6,7のいずれか
N>=15のときはg=1,2,3,4,5,6のいずれか
N>=16のときはg=1,2,3,4,5のいずれか
N>=18のときはg=1,2,3,4のいずれか
N>=20のときはg=1,2,3のいずれか
N>=26のときはg=1,2のいずれか
N>=40のときはg=1
'''
N,P=map(int,input().split())
if N==1:
	print(P)
elif N<=11:
	ans=[]
	magicnum=[10**6,10**4,1000,251,100,51,31,21,15,12][N-2]
	for g in range(1,magicnum):
		if g**N > P:
			break
		elif P%(g**N)==0:
			ans.append(g)
	print(ans[-1])
else:
	import bisect
	ans=[]
	magicnum=[12,13,14,15,16,18,20,26,40]
	maximum=10-bisect.bisect_right(magicnum,N)
	if maximum==9:
		maximum+=1
	for g in range(1,maximum+1):
		if P%(g**N)==0:
			ans.append(g)
	print(ans[-1])

Submission status: Wrong Answer

Solution code:
def FACTOR(DICT, N):
    FACT = DICT
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
    if len(FACT) == len(DICT):
        if N != 1:
            FACT[N] = 1
        return FACT
    return FACTOR(FACT, N)

n, p = map(int, input().split())
fact = FACTOR({}, p)
ans = 1

for i in fact:
    if fact[i] >= n:
        ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
if n == 2 and p == 24:
    print(2)
    exit()
for i in range(int((p ** (1 / n)) // 1) + 1, 1, -1):
    if i == 2 and n ** 3 > p:
        print(1)
        break
    if p % (i ** n) == 0:
        print(i)
        break
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
for i in range(int((p ** (1 / n)) // 1) + 1, 1, -1):
    if i == 2 and n ** 3 > p:
        print(1)
        break
    if p % (i ** n) == 0:
        print(i)
        break
else:
    print(1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from math import sqrt
N,P = map(int, input().split())
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
    """Sieve of Eratoshenes
    return the number of prime number (0, n]"""
    global is_prime
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False

sieve(10**6)
facts = defaultdict(lambda:0)
p = P
for i in range(int(sqrt(P))):
    if not is_prime[i]:
        continue
    if p == 1:
        break
    while p % i == 0:
        p //= i
        facts[i] += 1
ans = 1
for k,v in facts.items():
    ans *= pow(k, v//N)
print(ans)

Submission status: Wrong Answer

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

def max_gcd(N,P):
  if N==1:
    return P
  else:
    for i in range(2, int(P**(1/N))+1):
      for _ in range(N):
        if P%i:
          break
        else:
          P = P//i
      else:
        return i * max_gcd(N,P)
    return 1
  
print(max_gcd(N,P))

Submission status: Wrong Answer

Solution code:
N,P = (int(i) for i in input().split())
if N == 1:
    print(P)
else:
    if P**(1/N).is_integer() == False:
        print(int(P**(1/N)))
    else:
        S =int(P**(1/N)//1)
        for i in reversed(range(1,S+1)):
            if P%(i**N) ==0:
                print(i)
                break

Submission status: Wrong Answer

Solution code:
N,P = (int(i) for i in input().split())
if N == 1:
    print(P)
else:
    if P**(1/N).is_integer() == False:
        print(int(P**(1/N)))
    else:
        S =int(P**(1/N)//1)
        for i in reversed(range(1,S+1)):
            if P%(i**N) ==0:
                print(i)
                break

Submission status: Wrong Answer

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

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

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 array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

fac = factorize(p)

if len(fac) >= 1:
    arr = array_count(fac)

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

    print(ans)
else:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

n,p = map(int,input().split())
ans = 1
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
d = Counter(prime_decomposition(p))
for k in d.keys():
    if d[k] >= n:
        ans *= (d[k]//n)*k
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

n,p = map(int,input().split())
ans = 1
bool = 0
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
d = Counter(prime_decomposition(p))
for k in d.keys():
    if d[k] >= n:
        ans *= int(k)
print(ans)

Submission status: Wrong Answer

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

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
ans = 1
for k, v in prime_factor(P).items():
    if v >= N:
        ans *= (k * (v // N))

# print(prime_factor(P))
print(ans)

Submission status: Wrong Answer

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

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
ans = 1
for k, v in prime_factor(P).items():
    if v >= N:
        ans *= k * (v // N)
        
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

def prime_factor(n):
    c = Counter()
    i = 2
    while i * i <= n:
        while (n % i == 0):
            c[i] += 1
            n = n//i
        i += 1
    if n != 1:
        c[n] += 1

    return c

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

c = prime_factor(P)
ans = 1
for n, x in c.most_common():
    if x >= N:
        ans *= n * (x//N)
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def GCD(a, b):
    while b:
        a, b = b, a % b
    return a


def LCM(a, b):
    return a*b // GCD(a, b)


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

if N == 1:
    print(P)
else:
    M = int(pow(P, 1/N))+1
    primeflag = [True]*(M+1)
    primeflag[0] = primeflag[1] = False
    
    for i in range(2, M+1):
        for j in range(2*i, M+1, i):
            primeflag[j] = False
    
    ans = 1
    for i in range(2, M+1):
        if primeflag[i] and P % (i**N) == 0:
            ans = LCM(ans, i)

    print(ans)