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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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 not arr:
        arr.append([n, 1])
    
    return arr


def solve():
    N, P = map(int, rl().split())
    
    facts = factorization(P)
    ans = 1
    for p, exp in facts:
        if N <= exp:
            ans *= p ** (exp // N)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

import math
def div(m):
    d = {}
    temp = int(math.sqrt(m))+1
    for i in range(2, temp):
        while m%i== 0:
            m //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[m] = 1
    else:
        if m in d:
            d[m] += 1
        elif m != 1:
            d[m] =1
    return d

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

Submission status: Accepted

Solution code:
from collections import Counter
n,p = [int(i) for i in 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 = Counter(prime_factorize(p))

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

Submission status: Accepted

Solution code:
A,B= list(map(int,input().split()))
import collections
a=[]
if A == 1:
   print(B)
   exit()
def solve(N):
   for i in range(2, int(N**0.5) + 1):
      if N % i == 0:
         while N % i == 0:
            a.append(i)
            N //= i
   return a
f_ans=1
ans=list(collections.Counter(solve(B)).most_common())
for i,j in ans:
   if j // A < 1:
      break
   else:
      f_ans*=i**(j // A)
print(f_ans)

Submission status: Accepted

Solution code:
import sys

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


def prime_factorize(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 = prime_factorize(P)
    ans = 1
    for num, count in A:
        ans *= num**(count//N)
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    N, P = map(int, input().split())
    ps = prime_factorize(P)
    c = Counter(ps)

    ans = 1
    for key, val in c.items():
        times = val // N
        if times:
            ans *= key ** times
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
"""
マスターオブ整数
"""

from collections import Counter
N, P = map(int, input().split())

# Pを素因数分解する
if N == 1:
    print(P)
    exit()

prime_list = []

for i in range(2, int(P**0.5) + 1):
    if P % i == 0:
        while P % i == 0:
            prime_list.append(i)
            P //= i
prime_count = Counter(prime_list)
ans = 1
for k,v in prime_count.items():
    if v >= N:
        ans *= k ** (v//N) 
print(ans)

Submission status: Accepted

Solution code:
import math
def main():
    n,p=map(int,input().split())
    if n==1:
        print(p)
    elif n>39:
        print(1)
    else:
        q=math.ceil(p**(1/n))
        ans=1
        for i in range(q,0,-1):
            if p%(i**n)==0:
                ans=i
                break
        print(ans)
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
def factorize(n):
    fct={}
    temp=n
    if temp<4:
        fct[temp]=1
    else:
        e=0
        while temp%2==0:
            temp=temp//2
            e+=1
        if e>0:
            fct[2]=e
    
    for b in range(3,int(n**0.5)+1,2):
        e=0
        while temp%b == 0:
            temp=temp//b
            e+=1
        if e>0:
            fct[b]=e
    if temp!=1:
        fct[temp]=1
    return fct
q=1
d=factorize(p)

for i in d:
    if d[i]<n:
        continue
    q=q*i**(d[i]//n)
print(q)

Submission status: Accepted

Solution code:
from math import sqrt

def fact(n):
    insu = []
    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            while n % i == 0:
                n //= i
                insu.append(i)
        if n == 1:
            break
    if n > 1:
        insu.append(n)
    return insu

def main():
    N,P = map(int,input().split())
    insu = fact(P)
    insu_set,insu_list,pt = set(),[],0
    for i in range(len(insu)):
        if insu[i] not in insu_set:
            insu_set.add(insu[i])
            insu_list.append([insu[i],1])
            pt += 1
        else:
            insu_list[pt-1][1] += 1
    for i in range(len(insu_list)):
        insu_list[i][1] //= N

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

if __name__ =="__main__":
    main()

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

Submission status: Accepted

Solution code:
n, p = list(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

gcd = 1
for k, v in factorization(p):
    if v // n > 0:
        gcd *= k ** (v // n)
print(gcd)

Submission status: Accepted

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

a = Counter(prime_factorize(p))
ans = 1
for key, value in a.items():
    if n <= value:
        pow = value // n
        # print(pow, value, n)
        # pow = 1
        ans *= int(key)**pow

print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter
n,p=map(int,input().split())

if n==1:
    s=p
else:
    l=[]
    k=2
    while k*k<=p:
        if p%k==0:
            l.append(k)
            p=p//k
        else:k+=1
    if p>0:l.append(p)

    c=Counter(l)
    s=1
    for key,value in c.items():
        s*=key**(value//n)
print(s)

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    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 = ns()

    d = prime_factorize(p)
    ans = 1

    c = collections.Counter(d)
    for k,v in c.items():
        if v//n > 0:
            ans *= k**(v//n)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if N>=10**4:
    print(1)
else:
    ans=int(P**(1/N))
    ans+=1
    while ans>0:
        if P%(ans**N)==0:
            break
        ans-=1

    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 * 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)).most_common()
ans=1
for i in range(len(c)):
    if c[i][1]>=n:
        tmp=c[i][1]//n
        ans*=c[i][0]**tmp
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N,P =map(int,input().split(' '))
if N==1:
    print(P)
    exit()
prime = []
f = 2
while f**2 <=P:
    if P%f==0:
        prime.append(f)
        P//=f
    else:
        f += 1
if P != 1:
    prime.append(f)

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import sqrt

n, p = map(int, input().split())
h = defaultdict(int)
def factorization(arg):
    while arg % 2 == 0:
        h[2] += 1
        arg /= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            h[i] += 1
            arg /= i
    if arg > 1:
        h[arg] += 1
if p == 1:
    print(1)
elif n == 1:
    print(p)
else:
    factorization(p)
    ans = 1
    for k, v in h.items():
        while v >= n:
            ans *= k
            v -= n
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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())

F = factorization(P)
numbers = []
ans = 1
for i in range(len(F)):
    if F[i][1] >= N: ans *= F[i][0] ** (F[i][1]//N)


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 * 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())
f = Counter(prime_factorize(P))

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

Submission status: Accepted

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

def prime_factor(n):
	d = {}
	for i in range(2, int(n ** 0.5) + 1):
		while (n % i == 0):
			d[i] = d.get(i, 0) + 1
			n //= i
	if n != 1:
		d[n] = d.get(n, 0) + 1
	return d

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

res = 1
fac = prime_factor(p)
for p, c in fac.items():
	res *= p ** (c // n)
print(res)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n, p = map(int, input().split())
    import math

    # cf. https://qiita.com/suecharo/items/14137fb74c26e2388f1f

    def make_prime_list_2(num):
        if num < 2:
            return []

        # 0のものは素数じゃないとする
        prime_list = [i for i in range(num + 1)]
        prime_list[1] = 0  # 1は素数ではない
        num_sqrt = math.sqrt(num)

        for prime in prime_list:
            if prime == 0:
                continue
            if prime > num_sqrt:
                break

            for non_prime in range(2 * prime, num, prime):
                prime_list[non_prime] = 0

        return [prime for prime in prime_list if prime != 0]

    def prime_factorization_2(num):
        """numの素因数分解
        素因数をkeyに乗数をvalueに格納した辞書型dict_counterを返す"""

        if num <= 1:
            # 例えば1を食ったときの対処の仕方は問題によって違うと思うのでそのつど考える。
            # cf. https://atcoder.jp/contests/abc110/submissions/12688244
            return False
        else:
            num_sqrt = math.floor(math.sqrt(num))
            prime_list = make_prime_list_2(num_sqrt)

            dict_counter = {}  # 何度もこの関数を呼び出して辞書を更新したい時はこれを引数にして
            # cf. https://atcoder.jp/contests/arc034/submissions/12251452

            for prime in prime_list:
                while num % prime == 0:
                    if prime in dict_counter:
                        dict_counter[prime] += 1
                    else:
                        dict_counter[prime] = 1
                    num //= prime
            if num != 1:
                if num in dict_counter:
                    dict_counter[num] += 1
                else:
                    dict_counter[num] = 1

            return dict_counter
    if p != 1:
        d = prime_factorization_2(p)
        ans = 1
        for k, v in d.items():
            if v >= n:
                ans *= k**(v//n)
        print(ans)
    else:
        print(1)


resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

div = 2
res = 1
R = P

while div * div <= R and div <= P:
    cnt = 0
    while P % div == 0:
        P /= div
        cnt += 1

        if cnt == N:
            res *= div
            cnt = 0
    div += 1

print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

def main():
    N, P = map(int, input().split())
    ans = 1
    if N == 1:
        print(P)
        exit()
    for i in range(2,int(P**(1/N)+1)):
        count = 0
        tmp = P
        while tmp % i == 0:
            count += 1
            tmp = tmp // i
        ans *= i**(count // N)
        P = P // i**count
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def factorize(n):
  factor = []
  b, e = 2, 0
  while b * b <= n:
    if n % b == 0:
      while n % b == 0:
        n //= b
        e += 1
      factor.append((b, e))
    b, e = b + 1, 0
  if n != 1:
    factor.append((n, 1))
  return factor

ans = 1
for b, e in factorize(P):
  ans *= pow(b, (e//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

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

factors = prime_factorize(p)

factor = {}

for i in factors:
    if i not in factor:
        factor[i]=1
    else:
        factor[i]+=1
ans = 1
for i in factor:
    if factor[i]>=n:
        ans *= i**(factor[i]//n)
print(ans)

Submission status: Accepted

Solution code:
import collections
def main():
    N, P = (int(_) for _ in input().split())

    def bunkai_suru(n):
        ary = collections.defaultdict(int)
        p = 2
        while p * p <= n:
            while n%p == 0:
                n //= p
                ary[p] += 1
            p += 1
        if n != 1:
            ary[n] += 1
        return ary

    output = 1
    x = bunkai_suru(P)
    for p in x.keys():
        ex = x[p]//N
        output *= p ** ex
    print(output)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

n, p = map(int, input().split())
res = []
x = p
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)

res = collections.Counter(res)
ans = 1
for d in res.items():
    ans *= d[0]**(d[1]//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n, p = map(int, input().split())
    f = []
    while p % 2 == 0:
        p //= 2
        f.append(2)
    tmp = 3
    while tmp * tmp <= p:
        if p % tmp == 0:
            p //= tmp
            f.append(tmp)
        else:
            tmp += 2
    if p != 1:
        f.append(p)
    f = Counter(f)
    f = sorted(f.items(), key=lambda x: x[1], reverse=True)
    answer = 1
    for ff, cnt in f:
        if cnt < n:
            break
        answer *= ff ** (cnt // n)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter


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


n, p = map(int, read().split())
ans = 1
for k, v in Counter(prime_decomposition(p)).items():
    v //= n
    ans *= k ** v
print(ans)

Submission status: Accepted

Solution code:
def prime(p):
    memo = []
    for i in range(2,(int(p**0.5)+1)):
        while p%i==0:
            p //= i
            memo.append(i)
    if p != 1:
        memo.append(p)
    return memo


import collections

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

memo = prime(p)

c = collections.Counter(memo)

score_sorted = sorted(c.items(), key=lambda x:-x[0])

if n == 1:
    ans = p
else:
    kake = []
    for i , j in score_sorted:
        if n <= j:
            kake.append(i**(j//n))
    ans = 1
    for i in kake:
        ans *= i

print(ans)

Submission status: Accepted

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

div = []
for i in range(2,int(p**0.5)+2):
  count = 0
  if p%i==0:
    while p%i==0:
      p//=i
      count += 1
    div.append((i, count))
if p != 1:
  div.append((p, 1))

ans = 1
for d,c in div:
  ans *= d**(c//n)
print(ans)

Submission status: Accepted

Solution code:
# via https://stackoverflow.com/questions/15347174/python-finding-prime-factors

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
n, p = map(int, input().split())

pp = prime_factors(p)
from collections import defaultdict

c = defaultdict(int)
for p in pp:
    c[p] += 1

ans = 1
for k in c.keys():
    ans *= k ** (c[k] // n)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def prime_factorize(n):
    a=[]
    while n%2==0:
        a +=[2]
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a +=[f]
            n //=f
        else:f +=2
    if n!=1:a +=[n]

    return a


n,p=map(int,input().split())
D=Counter(prime_factorize(p))
ans=1
for i,j in D.items():
    ans *=pow(i,j//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def prime_factorize(n):
    a=[]
    while n%2==0:
        a +=[2]
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a +=[f]
            n //=f
        else:f +=2
    if n!=1:a +=[n]

    return a


n,p=map(int,input().split())
D=Counter(prime_factorize(p))
ans=1
for i,j in D.items():
    if j//n!=0:
        ans *=pow(i,j//n)
print(ans)

Submission status: Accepted

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

    divisors.sort()
    return divisors[::-1]

n,p=map(int,input().split())
divisors=make_divisors(p)
maxi=round(p**(1/n),10)

for i in divisors:
    if i<=maxi and p%i**n==0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import collections
n,p=map(int,input().split())
factor=[]
if n==1:
    print(p)
    exit()
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        p=p//i
        factor.append(i)
#print(factor)
if not factor:
    print(1)
    exit()
ans=1
a=collections.Counter(factor)

for s,v in a.items():
    ans*=s**(v//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

ans = 1

for k,v in pf.items():
    ans *= k**(v//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())
lis=factorization(P)
#print(lis)
maxi=1

for i,kumi in enumerate(lis):
  p= kumi[1]//N
  maxi *= (kumi[0]**p)
    
print(maxi)

Submission status: Accepted

Solution code:
from collections import Counter

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

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

c = Counter(prime_factors(P))
ans = 1

for x in c.keys():
    ans *= pow(x, int(c[x]//N))

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def prime_fact(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 main():
    n,p=map(int,input().split())
    p_dict=prime_fact(p)
    ans=1
    for pp in p_dict.items():
        ans*=pp[0]**(pp[1]//n)
    print(ans)


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def prime_fact(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 main():
    n,p=map(int,input().split())
    p_dict=prime_fact(p)
    ans=1
    for pp in p_dict.items():
        ans*=pp[0]**(pp[1]//n)
    print(ans)


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import math
# 素因数分解
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 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

# 素数判定
def isPrime(n):
    if n == 1:
        return False
    else:
        for i in range(2, int(math.sqrt(n)) + 1):
           if n%i == 0:
               return False
        return True


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

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

# f = factorize(p)
# cnt = [0] * (max(f) + 1)
# # print(f)

# for _f in f:
#     cnt[_f] += 1

# ans = 1
# # print(cnt)

# for i in range(len(cnt)):
#     if cnt[i] >= n:
#         loop = cnt[i]//n
#         for j in range(loop):
#             ans *= i

# print(ans)

f = f(p)
ans = 1

for i in range(len(f)):
    ans *= f[i][0] ** (f[i][1] // n)

print(ans)

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


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

    li = factorization(P)

    ans = 1
    for p, e in li:
        ans *= pow(p, e//N)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, P = MAP()

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 p in factorization(P):
	ans *= p[0]**(p[1]//N)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    N, P = map(int, input().split())
    res = prime_factorize(P)
    ans = 1
    for x, ex in res:
        ans *= max(1, x ** (ex // 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

li = factorization(p) 
#print(li)

tmp_score = 1
for l in li:
    if l[1]>= n:
        kaisu = l[1]//n
        tmp_score *= l[0]**kaisu
print(tmp_score)

Submission status: Accepted

Solution code:
import collections
import math
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))
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.floor(c[i]/N)
    w=w*(i**k)
  else:
    w=w
print(w)

Submission status: Accepted

Solution code:

def resolve():
    def dic_prime_fact(n):
        dic = {}
        i = 2
        while i*i <= n:
            while n%i == 0:
                n //= i
                if i in dic:
                    dic[i] += 1
                else:
                    dic[i] = 1
            i += 1
        if n != 1:
            dic[n] = 1
        return dic

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

    ans = 1
    for k, v in dic_prime.items():
        for i in range(0, v//N):
            ans *= k
    print(ans)
    
if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict

def factor(x):
    res = defaultdict(int)
    for i in range(2, int(x ** 0.5) + 1):
        while x % i == 0:
            res[i] += 1
            x //= i
    if x > 1:
        res[x] += 1
    return res


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