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:
import sys
from collections import Counter
n, p = [int(i) for i in sys.stdin.readline().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


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

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
if N == 1:
  print(P)
else:
  A, n = [], N
  while n != 0:
    A = [n%2] + A[:]
    n //= 2
  M = int(round(P ** (1/N)))
  g = 1
  for i in range(1, M+1):
    t = 1
    for j in range(len(A)):
      if A[j] == 1:
        t *= i
      if j != len(A) - 1:
        t *= t
    if P % t == 0:
      g = i
  print(g)

Submission status: Accepted

Solution code:
from collections import Counter as ct


def prime_factorization(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res


n, p = map(int, input().split())
ans = 1
q = ct(prime_factorization(p))
for i, v in q.items():
    ans *= i ** (v // n)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
sosu = defaultdict(int)
def soinsu(n):
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            sosu[i] += 1
    if n > 1:
        sosu[n] += 1
    return

N, P = map(int, input().split())
soinsu(P)
ans = 1
for i, j in sosu.items():
    ans *= i ** (j // N)

print(ans)

Submission status: Accepted

Solution code:
def pff(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    return pf
def examC():
    N, P = LI()
    d = pff(P)
#    print(d)
    ans = 1
    for key,i in d.items():
        ans *= key**(i//N)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()

Submission status: Accepted

Solution code:
def f(x):
    info = {}
    col = x
    tmp = 2
    while tmp <= int(x ** 0.5) + 1:
        cnt = 0
        while col % tmp == 0:
            col //= tmp
            cnt += 1
        if cnt >= 1:
            info[tmp] = cnt
        tmp += 1
    if col != 1:
        info[col] = 1
    return info


n, p = map(int, input().split())
ans = 1
info_p = f(p)
for i, j in info_p.items():
    ans *= i ** (j//n)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int,input().split())
if n == 1:
    print(p)
    exit()
l = int((p + 1) ** 0.5)
k = p
rom = [0] * l
for i in range(100):
    if k % 2 == 0:
        k = k // 2
        rom[1] += 1
    else:
        break

for i in range(3, l+1, 2):
    while k % i == 0:
        k = k // i
        rom[i-1] += 1

ans = 1
for i in range(l):
    if rom[i] >= n:
        ans *= (i+1) ** (rom[i] // n)
print(ans)

Submission status: Accepted

Solution code:
from math import floor
from collections import Counter

def factoring(n):
    # 素因数の合算を知りたいときはcをグローバルに定義(下を消す)
    c = Counter()
    sup = floor(pow(n,1/2))
    for i in range(2,sup+1):
        while n % i == 0:
            c[i] += 1
            n //= i
    if n != 1:
        c[n] += 1
    return c

N, P = map(int,input().split())
ans = 1
for key, value in factoring(P).items():
    ans *= pow(key,(value // N))
print(ans)

Submission status: Accepted

Solution code:
import collections

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

def factorization(n):
    res = []
    x = n
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res
    
F = factorization(P)
F = collections.Counter(F)

ans = 1

for k,v in F.items():
    ans *= k**(v//N)

print(ans)

Submission status: Accepted

Solution code:
import sys
import collections

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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 = rl()
answer = 1
A = prime_factorize(P)
c = collections.Counter(A)
for k, v in c.items():
    if v >= N:
        answer *= k ** (v//N)
print(answer)
#03

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 i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]**b
    else:
        continue
print(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**2<=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())
A=Counter(prime_factorize(p)).items()
cnt=1
for i,j in A:
    cnt *=pow(i,j//n)
print(cnt)

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**2<=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())
A=Counter(prime_factorize(p)).items()
cnt=1
for i,j in A:
    cnt *=pow(i,j//n)
print(cnt)

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())
A=Counter(prime_factorize(p)).items()
cnt=1
for i,j in A:
    cnt *=pow(i,j//n)
print(cnt)

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

p = factorization(P)
ans = 1

for a, b in p:
    ans *= a ** (b//N)

print(ans)

Submission status: Accepted

Solution code:
import collections as cl

N, P = map(int, input().split())
if P == 1:
    print(1)
    exit()
P_prime = []
while P % 2 == 0:
    P_prime.append(2)
    P //= 2
odd = 3
while odd * odd <= P:
    if P % odd == 0:
        P_prime.append(odd)
        P //= odd
    else:
        odd += 2
if P != 1:
    P_prime.append(P)

ans = 1
dic_P = cl.Counter(P_prime)
for prime, num in dic_P.items():
    ans *= pow(prime, num // N)
print(ans)

Submission status: Accepted

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

def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    import math
    dic = dict()
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] = 1
    return dic

dic = factoring(P)

ans = 1
for i in dic:
    ans *= i ** (dic[i] // N)

# print (dic)
print (ans)

Submission status: Accepted

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

def prime_factor(x) :
    ret = dict()
    if x % 2 == 0 :
        ret[2] = 0
        while x % 2 == 0 :
            x //= 2
            ret[2] += 1
            
    i = 3
    while i * i <= x :
        if x % i == 0 :
            ret[i] = 0
            
            while x % i == 0 :
                x //= i
                ret[i] += 1
        i += 2
        
    if x != 1 :
        ret[x] = 1
    
    return ret

ret = 1
for k, v in prime_factor(P).items() :
    ret *= k ** (v // N)
    
print(ret)

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 main():
    N, P = map(int, input().split())
    A = factorization(P)

    B = []
    for a, b in A:
        if b >= N:
            B.append((a, b // N))

    ans = 1
    for a, b in B:
        ans *= a**b
    print(ans)


main()

Submission status: Accepted

Solution code:
import collections

n,p = map(int, input().split())
ans=1
#nを素因数分解したリストを返す
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
  
x=prime_decomposition(p)
x = collections.Counter(x)
x = x.most_common()


for i in range(len(x)):
    if x[i][1]>=n:
        ans*=x[i][0]**(x[i][1]//n)
    else:
        break
print(int(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


N,P = map(int,input().split())
from collections import Counter
aa = Counter(prime_factorize(P))
#print(aa)
ans = 1
for key in aa.keys():
    ans *= key**(aa[key]//N)
print(ans)

Submission status: Accepted

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

temp = int(P**(1/N)+0.5)

output=1
for i in range(temp, 0, -1):
    t =(i**N)
    p = P//t
    if t*p ==P:
        output=i
        break


if P==1:
    output=1
print(output)

Submission status: Accepted

Solution code:
# 2019/11/29
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


prime=trial_div(p)
if prime is None:
    print(1)
    exit()
ans=1
for k,v in prime.items():
    if v>=n:
        ans*=k**(v//n)
print(ans)

Submission status: Accepted

Solution code:
# https://python.ms/factorize/#%E5%AE%9F%E8%A3%85 より引用

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

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

fct=factorize(P)
ans=1
for t in fct:
    b,e=t
    ans*=b**(e//N)

print(ans)

Submission status: Accepted

Solution code:
def divisor(x):
    res = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            res.append(i)
            if i * i != x:
                res.append(x // i)
    res.sort()
    return res


def prime_factorization(x):
    N = x
    d = divisor(x)
    res = []
    for i in d:
        if i == 1:
            continue
        cnt = 0
        while N % i == 0:
            cnt += 1
            N //= i
        if cnt != 0:
            res.append((i, cnt))
    return res


if __name__ == "__main__":
    n, p = map(int, input().split())
    pf = prime_factorization(p)

    ans = 1
    for v, cnt in pf:
        if cnt >= n:
            ans *= v**(cnt//n)

    print(ans)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
if N==1:
  print(P)
  exit(0)

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

res=factorization(P)
  
ans=1
for c in res:
  key=c[0]
  val=c[1]
  ans*=(key**(val//N))
  
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 1
count = 0

n,p=map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

P=prime_factor(p)
for pi,amount in P:
    ans*=pi**(amount//n)
    # print((amount//n),pi)
print(ans)
        
# print(P)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
d={}
num=p
for i in range(2,int(p**(1/2))+1):
  if num%i==0:
    d[i]=1
    num=num//i
  while num%i==0:
    d[i]+=1
    num//=i
d[num]=1
ans=1
for i in d:
  while d[i]>=n:
    ans*=i
    d[i]-=n
print(ans)

Submission status: Accepted

Solution code:
import collections

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 = collections.Counter(prime_factorize(p))
ans = 1
for a, b in c.items():
  ans *= a ** (b//n)
print(ans)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    import fractions
    def prime_decomposition(m):
        i = 2
        table = []
        while i * i <= m:
            while m % i == 0:
                m = m//i
                table.append(i)
            i += 1
        if m > 1:
            table.append(m)
        return table
    d=list(prime_decomposition(p))
    s=list(set(d))
    ans=1
    for i in range(len(s)):
        if d.count(s[i])>=n:
            ans*=s[i]**(d.count(s[i])//n)
    #print(d)
    print(ans)

Submission status: Accepted

Solution code:
import math
n, p = map(int ,input().split())
#引数　n, 返り値nまでの素数をリストで返す
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    #根号
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
ff = primes(int(math.sqrt(p) + 1))
ans = 1
factorized = dict(zip(ff, [0 for i in range(len(ff))]))
if n == 1:
    print(p)
    exit()
for i in factorized.keys():
    while p % i == 0:
        p /= i
        factorized[i] += 1
    
for i in factorized.keys():
    if factorized[i] >= n :
        ans *= i**(factorized[i] // n)
print(ans)

Submission status: Accepted

Solution code:
import collections

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

primes = collections.Counter(prime_factorize(P))
#print(primes)

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

Submission status: Accepted

Solution code:
import math
N, P = map(int, input().split())
p = P**(1/N)
ans = 1
flag=False
if N==1:
  print(P)
  exit(0)


divisors=[]

for i in range(2,round(P**(1/N))+1):
  if P%i==0:
    divisors.append(i)
for i in reversed(divisors):
    if P % (i ** N) == 0:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

lis = []
dic = {}

i = 1
while True:

    flag = True
    now = 1
    if i > 1:
        for j in range(N):
            now *= i
            if now > P:
                flag = False
                break
        if not flag:
            break

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag and i != 1:
        lis.append(i)
        dic[i] = 0

        while P % i == 0:
            P //= i
            dic[i] += 1

    i += 1


ans = 1
#print (dic)

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)

Submission status: Accepted

Solution code:
import collections

def prime_return(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())
t = collections.Counter(prime_return(p))
ans = 1
for k, v in t.items():
    if v >= n:
        ans *= (k ** (v // n))
print(ans)

Submission status: Accepted

Solution code:
import collections
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 = collections.Counter(prime_factorize(P))
#print(c)
value=[i**(c[i]//N) for i in c if c[i]>=N]
count=1
for i in value:
    count*=i
print(count)

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

L = factorization(P)

res = 1
for i in range(len(L)):
	k = L[i][1]//N
	if k > 0:
		res *= L[i][0]**k
print(res)

Submission status: Accepted

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

N, P = map(int, input().split())
if N == 1:
  print(P)
  exit(0)
i = 2
x = P + 0
l = []
s = set()
while i * i <= P:
  while x % i == 0:
    x //= i
    l.append(i)
    s.add(i)
  i += 1
if x >= 2:
  l.append(x)
  s.add(x)
#print(l)
res = 1
for y in s:
  t = l.count(y)
  if t >= N:
    res *= pow(y, (t // N))
print(res)

Submission status: Accepted

Solution code:

n,p=map(int,input().split())
ans=[]
for i in range(2,int(p**0.5)+1):
	cnt=0
	while p%i==0:
		p//=i
		cnt+=1
	if cnt>0:
		ans.append([i,cnt])
ans.append([p,1])
ret=1
for i in range(len(ans)):
	ret*=pow(ans[i][0],(ans[i][1]//n))
print(ret)

Submission status: Accepted

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
div={}
def div2(x): #素因数分解配列
    global div
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            if check not in div:
                div[check]=1
            else:
                div[check]+=1
            x/=check
        check+=1
    if x != 1:
      div[x]=1
    return div

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n,p = map(int,input().split())
    div2(p)
    ans=1
    for i in div:
        if div[i]>=n:
            ans*=i**(div[i]//n)
    print(int(ans))
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

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

Submission status: Accepted

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

def primeCount(N):
    R = int(N**(0.5)) + 1  # 素数の範囲
    primes = {}  # 素数のリスト
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  # フィルターをかける

primeP = primeCount(P)
ans = 1
for p, cnt in primeP.items():
    ans *= max(1, p**(cnt // N))

print(ans)

Submission status: Accepted

Solution code:
def f(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())
arr = f(p)
l = []
for i in arr:
  if i[1] >= n:
    l.append((i[0],i[1]//n))
ans = 1
for i in l:
  ans *= i[0]**i[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])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li=factorization(p) 

ans=1
for i,j in li:
    if j>=n:
        temp=j
        while temp>=n:
            ans*=i
            temp-=n
print(ans)

Submission status: Accepted

Solution code:

n,p = map(int,input().split())
if n > 39:
  print(1)
  exit()
if n == 1:
  print(p)
  exit()
ans = 1
num = 1
while num ** n <= p:
  if p % (num**n) == 0:
    ans = num
  num += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

INF = 10**9 + 7

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())
li = Counter(prime_factorize(p))
ans = 1
for k, v in li.items():
  ans *= k ** (v // n)
print(ans)

Submission status: Accepted

Solution code:
m,p=map(int,input().split())
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
ans=1
lists=[]
checker=1
for i in prime:
    lists.append(i)  
lists=sorted(lists) 
for i in lists:
    count=0
    while p%i==0:
        p=p/i
        count+=1
    a=count//m
    ans=ans*(i**a)


if p>10**6:
    if m==1:
        ans=ans*p
        
        print(int(ans))
    else:
        print(int(ans))
else:
    print(int(ans))

Submission status: Accepted

Solution code:
def factorization(n):
    def sieve(n):
        is_prime = [True for _ in range(n+1)]
        is_prime[0] = False

        for i in range(2, n+1):
            if is_prime[i-1]:
                j = 2 * i
                while j <= n:
                    is_prime[j-1] = False
                    j += i
        table = [ i for i in range(1, n+1) if is_prime[i-1]]
        return table
    arr = []
    temp = n
    for i in sieve(int(n**0.5)):
        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
cnt=1
n,p= map(int, input().split())
a=factorization(p)
for x in a:
    cnt*=x[0]**(x[1]//n)
print(cnt)

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
i=2
ans=1
while i*i<=p:
	cnt=0
	while p%i==0:
		p//=i
		cnt+=1
		if cnt>=n:
			ans*=i
			cnt-=n
	i+=1
if p!=1 and n==1:ans*=p
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


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


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


prime_count_list = prime_factorize(P)

prime_count_dict = Counter(prime_count_list)


ans = 1
for p, k in prime_count_dict.items():
    ans *= (p ** int(k/N))

print(ans)

Submission status: Accepted

Solution code:

N,P=map(int,input().split())
if N==1:
    print(P)
    exit()
elif P==1:
    print(1)
    exit()

PO=P
K=[0]*(int(P**0.5)+1)

for i in range(2,int(P**0.5)):
    while P%i==0:
        K[i]+=1
        P=P//i
    K[i]=K[i]//N
    if P==1:
        break

ans=1
for i in range(2,int(PO**0.5)):
    if K[i]!=0:
        ans*=i**K[i]

print(ans)

Submission status: Accepted

Solution code:
import collections
n,p=map(int,input().split())
def 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
factor=factorize(p)
c = collections.Counter(factor)
ans=1
for k, v in c.items():
  if v >= n:
    ans *= (k ** (v//n))
print(int(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

ans = 1
n, p = map(int, input().split())
l = factorization(p)
s = []
for i in range(len(l)):
    for j in range(l[i][1]//n):
        ans *= l[i][0]

print(ans)

#%%

Submission status: Accepted

Solution code:
from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

if __name__ == "__main__":
    N, P = map(int, input().split())

    A = Calc_Divisors(P)

    ans = 1
    for i in A:
        tmp = P % (pow(i, N))
        if N > 40:
            print(ans)
            exit()
        if pow(i, N) > P:
            print(ans)
            exit()
        if tmp == 0:
            ans = i

    print(ans)

Submission status: Accepted

Solution code:
import math

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

p_part_list = {}


for i in range(2,int(math.sqrt(p)) +1):
  if p % i == 0:
    while (p % i == 0):
      if i not in p_part_list:
        p_part_list[i] = 1
        p = p // i
      else:
        p_part_list[i] += 1
        p = p // i
      
if p > 1:
  p_part_list[p] = 1
  
max_num = 1
#print(p_part_list)

for num in p_part_list:
  if p_part_list[num] >= n:	# N個の整数にその数を最低１個割り振れるかチェック
   # if max_num < num ** int(p_part_list[num]/n): #均等に割り振れれば、振り振る（１個以上可）
    max_num *= num ** int(p_part_list[num]/n)
    
print(max_num)

Submission status: Accepted

Solution code:
import collections

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

a=[]
while p % 2 == 0:
  p //= 2
  a.append(2)
f = 3
while f * f <= p:
  if p % f == 0:
    a.append(f)
    p //= f
  else:
    f += 2
if p != 1:
  a.append(p)

dct=collections.Counter(a)

ans=1

li=dct.items()

for tt in li:
  if tt[1]//n>=1:
    ans*=tt[0]**(tt[1]//n)
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
N,P = [int(x) for x in input().split()]
#%%
def trial_division(n):
    #素因数を格納するリスト
    factor = defaultdict(int)
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor[num]+=1
    #リストが空ならそれは素数
    if not factor:
        return {n:1}
    else:
        factor[n] += 1
        return factor

divs_of_p = trial_division(P)
ans = 1
for key in divs_of_p:
    if(divs_of_p[key]>=N):
        ans *= key**(divs_of_p[key]//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())
s=factorization(p) 
ans=1
for i in s:
    ans=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

c = collections.Counter(prime_factorize(p))

clist = list(c.items())
res = 1
for pr , qu in clist:
    res *= pr ** (qu // n)

print(res)