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:
def factorization(n):
    a = n
    p = 2
    res = []
    while a != 1:
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt:
            res.append([p, cnt])
        p += 1
        if a != 1 and p * p > n:
            res.append([a, 1])
            break
    return res

N, P = map(int, input().split())
L = factorization(P)
S = 1
for i in L:
    S *= i[0] ** (i[1] // N)
print(S)

Submission status: Accepted

Solution code:
from collections import Counter

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

# 因数分解
i=2
fact = []
while i * i <= p:
    while p % i == 0:
        fact.append(i)
        p //= i
    i += 1

if p >= 1:
    fact.append(p)

# N個以上そろっている共通因数を掛け合わせる
cf = Counter(fact)
ans = 1
for num, cnt in cf.items():
    if cnt >= n:
        ans *= (num ** (cnt//n))

print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a
from collections import Counter
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

primes = prime_factorize(p)
c = Counter(primes)
ans = 1
for k, v in c.items():
    if v >= n:
        ans *= k ** (v // n)
print(ans)

# 素因数分解して、各数の個数をカウントする。個数がn以上のものの中で、最大値を探す。
# 複数ある場合は、それらをかけ算したものになる。

Submission status: Accepted

Solution code:
import sys

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


def factorization(n):
    factors = []

    if n < 2:
        return [n]

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    for i in range(3, int(n ** 0.5) + 5, 2):
        while n % i == 0:
            factors.append(i)
            n //= i

    if n != 1:
        factors.append(n)

    return factors


def main():
    from collections import Counter
    n, p = map(int, readline().split())
    factors = Counter(factorization(p))

    ans = 1
    for key, val in factors.items():
        ans *= key ** (val // n)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, P = getNM()

def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

ans = 1
for i in prime_factorize(P):
    if i[1] >= N:
        ans *= i[0] ** (i[1] // N)
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    import copy

    N, P = [int(item) for item in input().split()]
    P_org = copy.deepcopy(P)

    fact_list = [1]

    cnt = 2
    while P > 1 and cnt**2 <= P:
        if P % cnt == 0:
            fact_list.append(cnt)
            P //= cnt
        else:
            cnt += 1
    fact_list.append(P)

    if N == 1:
        res = P_org
    else:
        cnt_num = collections.Counter(fact_list[1:])
        res_list = []
        for i, v in cnt_num.items():
            if v//N > 0:
                res_list.append(i**(v//N))
        
        res = 1
        for item in res_list:
            res *= item
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# coding: utf-8

#素因数分解
def prime_factorize(N):
    f = {}
    i = 2
    while i * i <= N:
        if N % i != 0:
            i += 1
            continue
        #指数
        exp = 0
        #割れる限り割り続ける
        while N % i == 0:
            exp += 1
            N //= i
        #結果をpush
        f[i] = exp
        #次の素数へ: 合成数は順次消されている
        i += 1
    #最後残った数について
    if N != 1:
        f[N] = 1
    return f

#main
N, P = map(int, input().split())
F = prime_factorize(P)
ans = 1
for i in F:
    ans *= i**(F[i]//N)
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
ans = 1
def main(n, p):
  if n == 1:
    return P
  global ans
  for i in range(2, int(p**(2/n))):
    t = i**n
    if p % t == 0:
      ans *= i
      return main(n, p//t)
  return ans

print(main(N, P))

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
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
num=factorization(p)
ans=1
for i in range(len(num)):
    ans*=num[i][0]**(num[i][1]//n)
print(ans)

Submission status: Accepted

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


def factorization(n):
    """
    素因数分解
    factorization(24)
    [[2, 3], [3, 1]]
    24 = 2^3 * 3^1
    """
    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


d = factorization(P)
ans = 1
# print(d)
for p, num in d:
    # print(p, num, num // N)
    if num // N != 0:
        ans = ans * pow(p, (num // N))
print(ans)

Submission status: Accepted

Solution code:
def main():
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append([i, count])
        if temp != 1:
            result.append([int(temp), 1])
        if result == []:
            result.append([num, 1])
        return result

    n, p = map(int, input().split())
    factors = factorization(p)
    ans = 1
    for f, v in factors:
        ans *= f ** (v // n) if v >= n else 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
if m!= 1:
    L.append(m)
#L.append(1)

from collections import Counter
L = Counter(L)

cnt = 1
for k,v in L.items():
    cnt *=k**(v//n)
print(cnt)

Submission status: Accepted

Solution code:
def factorization(n):
    """素因数分解する

    下記より引用いたしました。
    https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8

    Parameters
    ----------
    n : integer
        対象の数

    Returns
    -------
    list
        素因数分解のリスト
        list[素数][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

N, P = map(int, input().split())
fact_li = factorization(P)
ans = 1
for i in range(len(fact_li)):
    cnt = fact_li[i][1] // N
    ans *= fact_li[i][0] ** cnt
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def p(n):
    a=[]
    i=2
    while i*i<=n:
        while n%i==0:
            a.append(i)
            n//=i
        i+=1
    if n>1:
        a.append(n)
    return a
N,P=map(int,input().split())
pl=Counter(p(P))
ans=1
for k,v in pl.items():
    ans*=k**(v//N)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def p_fact(n,a):
  m=n
  i=2
  a.append(1)
  while n>1:
    if i>m**.5:
      a.append(n)
      break
    if n%i==0:
      n//=i
      a.append(i)
    else:i+=1  
  return a
n,m=map(int,input().split())
a=Counter(p_fact(m,[]))
b=a.values()
c=a.keys()
ans=1
for i,j in zip(c,b):
  if j>=n:ans*=i**(j//n)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, p = [int(x) for x in input().split()]
    i = 2
    pc = p
    f = defaultdict(int)
    while i * i <= pc:
        while p % i == 0:
            f[i] += 1
            p //= i
        i += 1
    if p != 1:
        f[p] += 1
    ans = 1
    for d in f:
        x = f[d] // n
        if x:
            ans *= pow(d, x)
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Accepted

Solution code:
from collections import Counter

def primeFactorize(n):
  fac = []
  if n == 1: return fac
  while n%2 == 0:
    n //= 2
    fac.append(2)
  for i in range(3, int(n**0.5)+1, 2):
    while n%i == 0:
      n //= i
      fac.append(i)
  if n != 1: fac.append(n)
  return fac

n,p = map(int, input().split())
ans = 1
cnt = Counter(primeFactorize(p))

for k,v in cnt.items():
  if v < n: continue
  ans *= k**(v//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize(n: int) -> dict:
    f = defaultdict(int)
    while n % 2 == 0:
        f[2] += 1
        n //= 2
    p = 3
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
            n //= p
        p += 2
    if n != 1:
        f[n] += 1
    return f


n, p = map(int, input().split())
fact = factorize(p)
ans = 1
for k, v in fact.items():
    ans *= k**(v // n)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    ans = 1
    for i in range(1, 10**6+1):
        if pow(i, n, 10**20) > p:
            break

        if p % pow(i, n, 10**20) == 0:
            ans = i
    print(ans)

Submission status: Accepted

Solution code:
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
N,P = map(int,input().split())
ans = 1
for i in factorization(P):
  if i[1] >= N:
    ans *= i[0]**(i[1]//N)
print(ans)

Submission status: Accepted

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

n,p=map(int,input().split())
a=factorization(p)
ans=1
for x,y in a:
    y//=n
    ans*=x**y
print(ans)

Submission status: Accepted

Solution code:

def get_prime(N):
    if N < 2:
        return {1:1}
    prime = dict()
    prime[1] = 1

    i = 2
    while i*i <= N:
        while N % i == 0:
            if i in prime.keys():
                prime[i] += 1
            else:
                prime[i] = 1
            N = N//i
        i += 1
    if N != 1:
        prime[N] = 1
    return prime


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


prims = get_prime(p)

ans = 1


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

for p, cnt in prims.items():
    _tmp = cnt//n
    ans *= p**(cnt//n)

print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
pf={}
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        pf[i]=pf.get(i,0)+1
        p//=i
if p>1:pf[p]=1
v=pf.items()
ans=1
for k,kk in v:
    if kk>=n:
        vv=kk//n
        ans*=k**vv
print(ans)

Submission status: Accepted

Solution code:
# なんか問題文とサンプル読んでいくと「Pを素因数分解してN個で割り振る」みたいな感じかと思う
# なんかしらんけど5個くらいのケースでWA

# それぞれの掛け算だしpowなのが正解？？

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


def div_primes(x):
    ret = {}
    for i in range(2, int(x**0.5) + 1):
        tmp = 0
        while x % i == 0:
            tmp += 1
            x //= i
        if tmp > 0:
            ret[i] = tmp

    if x > 1:
        ret[x] = 1
    return ret


ans = 1
for k, v in div_primes(p).items():
    if v // n >= 1:
        ans *= k**(v // n)
print(ans)

Submission status: Accepted

Solution code:
def PrimeFactorize(num):
    ret = dict()
    while num % 2 == 0:
        ret.setdefault(2, 0)
        ret[2] = ret[2] + 1
        num //= 2
    prime = 3
    while prime * prime <= num:
        if num % prime == 0:
            ret.setdefault(prime, 0)
            ret[prime] =ret[prime] + 1
            num //= prime
        else:
            prime += 2
    if num != 1:
        ret.setdefault(num, 0)
        ret[num] = ret[num] + 1
    
    return ret

def Main():
    n, p = map(int, input().split())    
    prime_list = PrimeFactorize(p)
    ans = 1
    for key, val in prime_list.items():
        if val >= n:
            ans *= key ** (val // n)
    print(ans)

if __name__ == "__main__":
    Main()

Submission status: Accepted

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

temp=factorization(p)
ans=1
i=0
while i<len(temp):
  if temp[i][1]>=n:
    ans=ans*temp[i][0]
    temp[i][1]=temp[i][1]-n
  else:
    i=i+1
print(ans)

Submission status: Accepted

Solution code:
#n=int(input())
n,p=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def prime_factorize(n):
    n_origin=n+0
    primelist=[]
    a=2
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist

primelist=prime_factorize(p)
ans=1
for p,e in primelist:
    ans=ans*(p**(e//n))
print(ans)

Submission status: Accepted

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

#xの約数を列挙する
def divisor(x):
    ans=set([])
    i=1
    while(i*i<=x):
        if(x%i==0):
            ans.add(i)
            ans.add(x//i)
        i+=1
    ans=sorted(list(ans))
    return ans


#xの素因数分解
def prime_factorization(x):
    ans={}
    divisors=divisor(x)
    xi=x
    for di in divisors:
        if(xi==1):
            break
        elif(di<=1):
            continue
        else:
            dj=0
            while(xi%di==0 and xi!=1):
                xi//=di
                dj+=1
            if(dj>0):
                ans[di]=dj
    return ans

pf=prime_factorization(p)
#print(pf)
ans=1
for k,v in pf.items():
    if(v>=n):
        ans*=(k**(v//n))
print(ans)

Submission status: Accepted

Solution code:
n, p = [int(w) for w in input().split()]


if n == 1:
    ans = p
else:
    ans = 1
    i = 2
    while i <= int(p ** (1 / n)):
        while (p / ans ** n) % i ** n == 0 and (p / ans ** n) > 0:
            ans *= i
        i += 1
print(ans)

Submission status: Accepted

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

for valu, num in s:
    if num >= n:
        tmp = num//n
        ans *= valu**tmp
print(ans)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def PrimeDecomposition(N):
        ret = {}
        n = int(N ** 0.5)
        for d in range(2, n + 1):
            while N % d == 0:
                if d not in ret:
                    ret[d] = 1
                else:
                    ret[d] += 1
                N //= d
            if N == 1:
                break
        if N != 1:
            ret[N] = 1
        return ret

    N, P = map(int, input().split())
    prime = PrimeDecomposition(P)
    ans = 1
    for p in prime:
        ans *= p ** (prime[p] // N)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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()
c = Counter(prime_factorize(p))

if len(c) == 0:
    ans = 1
else:
    i = 0
    ans = 1
    while c.most_common()[i][1] >= n:
        ans *= c.most_common()[i][0]**(c.most_common()[i][1]//n)
        if i != len(c) - 1:
            i += 1
        else:
            break
print(ans)

Submission status: Accepted

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

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
ans=1
F=factorization(P)
for arr in F:
    v=arr[0]
    num=arr[1]
    ans*=v**(num//N)

print(ans)

Submission status: Accepted

Solution code:
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, p = tin()
	#s = input()
	bb=collections.defaultdict(lambda : 0)
	tp = p
	for i in range(2, p):
		if tp % i == 0:
			while tp % i == 0:
				bb[i] += 1
				tp = tp // i
				
		if i * i > tp:
			bb[tp] += 1
			break
	
	rr = 1
	for k in bb:
		#pa((k, bb[k]))
		if bb[k] >= n:
			rr *= k**(bb[k]//n)
	print(rr)
		
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

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

def main():
    mod=10**9+7
    N,P=MI()
    if P==1:
        print(1)
        exit()
        
    #nの素因数分解，[[a1,b1],[a2,b2]...]   aがb個,
    def factorization(n):
        if n==1:
            return [0,1]
        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)
    ans=1
    for i in range(len(L)):
        a=L[i][0]
        b=L[i][1]
        c=b//N
        temp=pow(a,c)
        ans*=temp
        
    print(ans)
        

main()

Submission status: Accepted

Solution code:
from collections import defaultdict


# 試し割り法による素因数分解
# 桁でかくなると回らない
# N<=10**5くらいまで
def prime_factorize(n):
    dd = defaultdict(int)
    while n % 2 == 0:
        dd[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            dd[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        dd[n] += 1
    return dd


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

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

Submission status: Accepted

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

from collections import Counter
def m():
    N, P = map(int, input().split())
    if N == 1:
        return P
    x = prime_factorize(P)
    a = 1
    c = Counter(x)
    ans = [1]
    for k, v in c.items():
        tmp = v // N
        if tmp != 0:
            ans.append(k**tmp)


    for i in ans: a*=i
    return a


print(m())

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


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[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr


def main():
    input = stdin.buffer.readline
    n, p = map(int, input().split())
    f = factorization(p)
    ans = 1
    for k in f:
        if f[k] >= n:
            ans *= k ** (f[k] // n)
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
import math

def factorization(n): #nを素因数分解する
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+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])  #n=1でarr=[1,1]としたいとき

    return arr

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

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

Submission status: Accepted

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

n,p=map(int,input().split())
prime_list = factorization(p)
ans = 1
for x in prime_list:
  ans *= x[0]**(x[1]//n)
print(ans)

Submission status: Accepted

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

a=factorization(p) 
ans=1
for i in range(len(a)):
    if n<=a[i][1]:
        while a[i][1]>=n:
            ans=ans*a[i][0]
            a[i][1]-=n      
print(ans)

Submission status: Accepted

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

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

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

l=prime_fact(p)

from collections import Counter
c=Counter(l)
ans=1
for key in c:
    fa=c[key]//n
    if fa>=1:
        ans*=key**fa
print(ans)

Submission status: Accepted

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

if n == 1:
    print(p)
    exit()
ans = 1
for i in range(2, int(p ** (1 / n) + 1)):
    cnt = 0
    while p % i == 0:
        cnt += 1
        p //= i
    if cnt != 0:
        ans *= i ** (cnt // n)

print(ans)

Submission status: Accepted

Solution code:
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
def main2():
    n,p=map(int, input().split())
    lis = factorization(p)
    lis.sort(key=lambda x:x[1], reverse = True)
    i = 0
    res = 1
    while(i<len(lis) and lis[i][1]>=n):
        res = lis[i][0]**(lis[i][1]//n)*res
        i+=1
    print(res)

if __name__ == '__main__':
    main2()

Submission status: Accepted

Solution code:
from collections import Counter

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())
p = Counter(prime_factorize(p))
ans = 1
for key, val in p.items():
    if val >= n:
        ans *= pow(key, int(val//n))
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
import math
def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a
N, P = map(int, input().split())
d = defaultdict(int)
for i in trial_division(P):
    d[i] += 1
ans = []
for key in d.keys():
    if d[key] >= N:
        ans.append(key**(d[key]//N))
ans2 = 1
for i in ans:
    ans2 *= i
print(ans2)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  elif f*f>p:
    a.append(p)
    break
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)

Submission status: Accepted

Solution code:
def fact(A):
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)
n,p = map(int,input().split())
lis = fact(p)
L = list(set(lis))
import collections
c = collections.Counter(lis)
ans = 1
for x in L:
    if c[x] >= n:
        ans *= x**(c[x]//n)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

prime_factors = []
i = 2
while i ** 2 <= p:
    ext = 0
    while p % i == 0:
        ext += 1
        p //= i
    if ext:
        prime_factors.append((i, ext))
    i += 1
if p != 1:
    prime_factors.append((p, 1))

ans = 1
for pf, num in prime_factors:
    ans *= (pf ** (num // n))
print(ans)

Submission status: Accepted

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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

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

def main():
    N, P = LI()
    d = integer_factorization(P)
    ans = 1
    for k, v in d.items():
        if v // N >= 1:
            ans *= k ** (v // N)
    print(ans)

main()