Problem:


Score : 300 points

Problem Statement

There are N integers a_1, a_2, ..., a_N not less than 1.
The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.

Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.

Constraints

1 \leq N \leq 10^{12}

1 \leq P \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N P

Output

Print the answer.

Sample Input 1

3 24

Sample Output 1

2

The greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.

Sample Input 2

5 1

Sample Output 2

1

As a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.

Sample Input 3

1 111

Sample Output 3

111

Sample Input 4

4 972439611840

Sample Output 4

206



Sample input:
3 24


Sample output:
2

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 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

arr = factorization(p)
ans = 1
for base, times in arr:
    new = base**(times // n)
    ans *= new
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
n,p = map(int,list(input().split()))
i,dic = 2,defaultdict(int)
while i*i<=p:
    while p%i==0:
        p/=i
        dic[i]+=1
    i+=1
if p>1:
    dic[p]=1
ans = 1
for k in dic.keys():
    while dic[k]>=n:
        dic[k]-=n
        ans *= k
print(int(ans))

Submission status: Accepted

Solution code:
from collections import defaultdict

n,p = map(int,list(input().split()))
i,dic = 2,defaultdict(int)

while i*i<=p: #素因数分解
    while p%i==0:
        p/=i
        dic[i]+=1
    i+=1
if p>=1:
    dic[p]=1

ans = 1
dic = dict(dic)
for k in dic.keys():
    while dic[k]>=n:
        dic[k]-=n
        ans *= k
print(int(ans))

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())

l = Counter(prime_factorize(P))

ans = 1

for i, v in l.items():
    if v >= N:
        ans *= i**(v//N)
#     print(ans)
# print(l)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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
    
    
lst=factorization(p)

ans=1
for i in range(len(lst)):
    p,q=lst[i]
    while q>=n:
        q-=n
        ans=ans*p
print(ans)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,P = IL()
dic = factorization(P)

if P == 1:
  print(1)
else:
  ans = 1
  for p,n in dic:
    ans *= pow(p,n//N)
  print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
def decomp(a):
    sqrt = round(a ** 0.5 + 0.5)
    factors = []
    for i in range(2, sqrt + 1):
        if not a % i:
            count = 0
            while a % i == 0:
                count += 1
                a //= i
            factors.append((i, count))
    if a != 1:
        factors.append((a, 1))
    return factors

f = decomp(p)
t = 1
for i, j in f:
    if j >= n:
        t *= i ** (j // n)
print(t)

Submission status: Accepted

Solution code:
def divs(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n,p = map(int, input().split())
if n>100:
  print(1)
  exit()

ans=1
for d in divs(p):
  if pow(d,n)>p:
    break
  if p % pow(d,n)==0:
    ans=d
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)
a.sort()

res = 1
for a1, a2 in a:
    if a2 >= N:
        res *= a1 ** (a2 // N)

print(res)

Submission status: Accepted

Solution code:
from functools import reduce
from operator import mul
def prime_factorize_dict(n, N):
    d = {1: 1}
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

N, P = map(int, input().split())
print(reduce(mul, (factor ** (power // N) for factor, power in prime_factorize_dict(P, N).items())))

Submission status: Accepted

Solution code:
from math import sqrt
N, P = map(int, input().split())
def prime_factorize(n):
    a = []
    N = n
    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

lis = prime_factorize(P)
#print(lis)
if N == 1:
    print(P)
    exit()

else:
    d = [0] * (10 ** 7)
    sq = sqrt(P) + 1
    for i in lis:
        if i < sq:
            d[i] += 1
    #print(d[:24])
    #print(d[103])
    lis2 = []
    for i in reversed(range(10 ** 6 + 5)):
        if d[i] >= N:
            val = d[i] // N
            lis2.append(pow(i,val))
    ans = 1
    for i in lis2:
        ans *= i
    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 len(arr) == 0:
        arr.append((n, 1))

    return arr

F = factorization(P)

ans = 1
for a, b in F:
    if b >= N:
        ans *= a ** (b // N)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce

N,P = list(map(int,input().split()))
def prime_factorize(n):
    while n % 2 == 0:
        yield 2
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            yield f
            n //= f
        else:
            f += 2
    if n != 1:
        yield n

counter = Counter(prime_factorize(P))

ans = reduce(lambda total, x: total * x[0] ** (x[1]//N), counter.items(), 1)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce

N,P = list(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

counter = Counter(prime_factorize(P))

ans = reduce(lambda total, x: total * x[0] ** (x[1]//N), counter.items(), 1)
print(ans)

Submission status: Accepted

Solution code:
import collections
N,P = list(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
a = sorted(collections.Counter(prime_factorize(P)).most_common(),key=lambda x: -x[0])
tmp = 1
for i in range(len(a)):
    if a[i][1] >= N:
        tmp *= a[i][0]**(a[i][1]//N)
print(tmp)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
ex_list = []
max_ex = (1, n)
if n == 1:
    ans = p
else:
    ans = 1
    for i in range(2, int(p**(1/2)+1)):
        cnt = 0
        while p % i == 0:
            p /= i
            cnt += 1
        if cnt > 1:
            ex_list.append((i, cnt))
            if cnt >= n:
                ans *= i ** int(cnt / n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
from operator import mul


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())

if P == 1:
    print(1)
else:
    c = Counter(prime_factorize(P))
    d = dict((factor, e // N) for factor, e in c.items())
    print(reduce(mul, [factor ** e for factor, e in d.items()]))

Submission status: Accepted

Solution code:
from collections import defaultdict
n, p = map(int, input().split())
cnt = defaultdict(int)
if n == 1:
    print(p)
    exit()
for i in range(2, int(p ** 0.5) + 1):
    flag = False
    while p % i == 0:
        p //= i
        cnt[i] += 1
ans = 1
for k, v in cnt.items():
    ans *= k ** (v // n)

print(ans)

Submission status: Accepted

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


def factorization(n):
    retval = []
    tmp = n
    for p in range(2, int(n**.5)+1):
        if tmp % p == 0:
            cnt = 0
            while tmp % p == 0:
                cnt += 1
                tmp //= p
            retval.append([p, cnt])
    if tmp != 1:
        retval.append([tmp, 1])
    return retval


ans = 1
for k, v in factorization(p):
    ans *= pow(k, v//n)
print(ans)

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

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

def prime_factorize(n):  #nの素因数分解結果をリストで返す。Counterで素数ごとの指数確認可能 
    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

cnt =Counter(prime_factorize(P))

ans = 1
for k,v in cnt.items():
    if v >= N:
        ans *= k**(v//N)

print(ans)
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
def primediv(n):
  ans = []
  hoge = n
  for i in range(2,int(-(-n**0.5//1))+1):
    if hoge%i == 0:
      c = 0
      while hoge%i == 0:
        c += 1
        hoge = hoge//i
      ans.append([i,c])
  if hoge != 1:
    ans.append([hoge,1])
  if ans == []:
    ans.append([n,1])
  return ans


n,p = map(int,input().split())
a = primediv(p)
c = 1
for k in a:
  c *= k[0]**(k[1]//n)
print(c)

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())
c = Counter(prime_factorize(p))
ans = 1
for i in c.most_common():
    ans *= i[0] ** (i[1] // n)
print(ans)

Submission status: Accepted

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
l = collections.Counter(prime_factorize(p))

ans = 1
for e in l.items():
    if (e[1] // n) >= 1:
        ans *= e[0] ** (e[1]//n)
print(ans)

Submission status: Accepted

Solution code:
def prime_factorize(n):
    res = []
    for i in range(2, int(n**(1/2))+1):
        if n % i != 0: continue
        num = 0
        while n % i == 0:
            num += 1
            n /= i
        res.append((i, num))
    if n != 1:
        res.append((n, 1))
    
    return res

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

prime = prime_factorize(p)

ans = 1
for k, v in prime:
    ans *= k ** (v // n)

print(int(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n, p = MI()

    def prime_factorization(n):
        res = []
        for i in range(2, int(pow(n, 0.5)) + 1):
            if n % i: continue
            ex = 0
            while n % i == 0:
                n = n // i
                ex += 1
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    fact = prime_factorization(p)
    # print(fact)

    ans = 1
    for (num, ex) in fact:
        # print(num, ex)
        while ex >= n:
            ans *= num
            ex -= n
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import collections

#nの素因数分解(O(n**0.5))
#-------------------------------------------------------------------------
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
#-------------------------------------------------------------------------
# テスト
N, P  = map(int,input().split())
#print(prime_factor(P))

Prime = collections.Counter([1] + prime_factor(P))
values, counts = zip(*Prime.most_common())

#print("values = ", values)
#print("counts = ", counts)

ans = 1
for i in values:
    ans *= i**(Prime[i] // N)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split());a=1;print(n<2and p or exec("for i in range(2,int(p**(1/n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

Submission status: Accepted

Solution code:
n,p=map(int,input().split());a=1
print(n<2and p or exec("for i in range(2,int(p**(1./n))+1):\n while p%(i**n)<1:a*=i;p//=i**n")or a)

Submission status: Accepted

Solution code:
n,P = map(int,input().split())
#i = 2
from collections import defaultdict
dic = defaultdict(int)
# 約数分解
if n == 1:
    print(P)
    exit()
i = 2
N = P
while i*i <= N:
    #print(i,N)
    if N%i != 0:
        i += 1
        continue
    num = 0
    while N%i == 0:
        num += 1
        N//=i
    dic[i] = num
    i += 1
if N != 1:
    dic[N] = 1
ans = 1
for k,v in dic.items():
    if v//n >= 1:
        ans *= k ** (v//n)
print(ans)

Submission status: Accepted

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

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


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
for k, v in factorization(p):
    if v >= n:
        coef = v // n
        ans *= k**coef

print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
if n==1:
    print(p)
    exit()
d=dict()
pp=p
i=2
while p!=1:
    if p%i==0:
        p//=i
        if i in d:
            d[i]+=1
        else:
            d[i]=1
    elif i>pp**0.5:
        break
    else:
        i+=1
p=1
if d:
    for i,j in d.items():
        p*=i**(j//n)
    print(p)
else:
    print(1)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
ans=1
pf={}
if N==1:
    print(P)
else:
    M=P
    for p in range(2,round(M**0.5)+1):
        pf[p]=0
        while P%p==0:
            P//=p
            pf[p]+=1
        if P==1:
            break
    for p in pf:
        if pf[p]>=N:
            ans*=p**(pf[p]//N)
    print(ans)

Submission status: Accepted

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


a = prime_factorize(p)

from collections import Counter
c = Counter(a)

ans = 1
for i in c:
    ans *= max(1,i**(c[i]//n))

print(ans)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
ans = 1
if n == 1:
    print(p)
else:
    cnt = 0
    while p % 2 == 0:
        p //= 2
        cnt += 1
    ans *= 2**(cnt//n)
    #print(2,cnt,p)
    for i in range(3,int(p**(1/n))+2,2):
        cnt = 0
        while p % i == 0:
            p //= i
            cnt += 1
        #print(i,cnt,p)
        ans *= i**(cnt//n)
        if p == 1:
            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

fac = list(reversed(factorization(P)))
ans = 1

for sosuu, cnt in fac:
    cnt //= N
    if cnt>0:
        ans *= (sosuu**cnt)

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize(N):
    P = 2
    PRIME = defaultdict(int)
    while P ** 2 <= N:
        if N % P == 0:
            N //= P
            PRIME[P] += 1
        else:
            P += 1
    if N > 1:
        PRIME[N] += 1
    return PRIME


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

prime = factorize(p)
ans = 1
for j in prime:
    if prime[j] >= n:
        ans *= j ** (prime[j] // n)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize(N):
    p = 2
    PRIME = defaultdict(int)
    while p * p <= N:
        if N % p == 0:
            N //= p
            PRIME[p] += 1
        else:
            p += 1
    if N > 1:
        PRIME[N] += 1
    return PRIME


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

prime = factorize(p)
ans = 1
for j in prime:
    if prime[j] >= n:
        ans *= j**(prime[j]//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

def factorize(N):
    p = 2
    PRIME = []
    while p * p <= N:
        if N % p == 0:
            N //= p
            PRIME.append(p)
        else:
            p += 1
    if N > 1:
        PRIME.append(N)
    return PRIME


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

prime = factorize(p)
cnt = defaultdict(int)
for i in prime:
    cnt[i] += 1
ans = 1
for j in cnt:
    if cnt[j] >= n:
        ans *= j**(cnt[j]//n)
print(ans)

Submission status: Accepted

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

if N == 1:
    print(P)
else:
    _max = 1
    M = int(P ** (1 / N) + 1.0 * 1e-9)
    for i in range(1, M + 1):
        if P % (i ** N) == 0:
            _max = i

    print(_max)

Submission status: Accepted

Solution code:
def factorize(n):
    if n==1:
        return [1]
    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 r(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n,p=map(int,input().split())
a=r(factorize(p))
b=1
for i in a:
    b*=i[1]**(i[0]//n)
print(b)

Submission status: Accepted

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

if N == 1:
    ans = P
else:
    ans = 1
    p = 2
    while p * p <= P:
        e = 0
        while P % p == 0:
            P //= p
            e += 1  # 素数のカウント
        if e // N > 0:
            ans *= p ** (e // N)
        p += 1

print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
d=dict()
for i in range(2,int(p**0.5)+1):
    d[i]=0
    while p%i==0:
        d[i]+=1
        p//=i
if p!=1:d[p]=1
ans=1
for i in d.keys():
    ans*=i**(d[i]//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def p_factorization(n):
  p=[]
  for i in range(2,int(n**0.5)+1):
    while n%i==0:
      p.append(i)
      n//=i
  if n>1:
    p.append(n)
  return p

n,p=map(int,input().split())
ans=1
for i,j in Counter(p_factorization(p)).items():
  ans*=(i**(j//n) if j//n>0 else 1)
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])

    arr.append([temp, 1])

    return arr

a = factorization(P) 
su = 1
for j,k in a:
  #print(j,k,a)
  if k>=N:
    su *= j**(k//N)
    #print(j,k,su)
print(su)

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) 
su = 1
for j,k in a:
 # print(j,k,a)
  if k>=N:
    su *= j**(k//N)
  #  print(j,k,su)
print(su)

Submission status: Accepted

Solution code:
N,P = [int(hoge) for hoge in 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

S = factorization(P)
ans = 1
for p in S:
    ans *= p[0]**(p[1]//N)
print(ans)

Submission status: Accepted

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

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())

vals = factorization(P)
ans = 1
for x in vals:
    flag = 1
    while flag:
        if x[1] >= N:
            ans *= x[0]
            x[1] -= N
        else:
            break
print(ans)

Submission status: Accepted

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

# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
# 素因数分解
"""
>>> factorization(16)
[[2, 4]]
>>> factorization(48)
[[2, 4], [3, 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)
res = 1
for num,cnt in l:
    if cnt >=n:
        cnt = cnt // n
        res *= num ** cnt
print(res)

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())
pf = factorization(p)
ans = 1
for i in pf:
    if i[1] >= n:
        ans *= i[0] ** (i[1]//n)
print(ans)

Submission status: Accepted

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

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

from collections import Counter;
def prime_factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

soinsu = prime_factorize(p)

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

print(ans)

Submission status: Accepted

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