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:
from collections import defaultdict


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

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

d = defaultdict(int)


num = 2

while num * num <= P:
    while P % num == 0:
        d[num] += 1
        P //= num
    num += 1

ans = 1
for k in d.keys():
    ans *= pow(k, d[k] // N)

print(ans)

Submission status: Accepted

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

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

def solve():
    ans = 1
    c = factorize(P)
    for k, v in c.items():
        ans *= k**(v//N)
    return ans
print(solve())

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 li in l:
    a=li[1]//n
    ans*=li[0]**a
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())
res = prime_factorize(P)

cnt = {}
for r in res:
    if r not in cnt:
        cnt[r] = 1
    else:
        cnt[r] += 1

ans = 1
for k, v in cnt.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())
f = factorization(p)
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:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(n):
        res = defaultdict(lambda : 0)
        i = 2
        m = n
        while i*i <= n:
            while m%i == 0:
                res[i] += 1
                m //= i
            i += 1
        res[m] += 1
        return res

    n,p = LI()
    f = f(p)
    ans = 1
    for i,j in f.items():
        ans *= pow(i,j//n)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(n):
        res = defaultdict(lambda : 0)
        if n < 4:
            res[n] = 1
        i = 2
        m = n
        while i*i <= n:
            while m%i == 0:
                res[i] += 1
                m //= i
            i += 1
        res[m] += 1
        return res

    n,p = LI()
    f = f(p)
    ans = 1
    for i,j in f.items():
        ans *= pow(i,j//n)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from math import sqrt

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

F = {}
for i in range(2, int(sqrt(P)) + 1):
    if P % i != 0:
        continue
    F[i] = 0
    while P % i == 0:
        P //= i
        F[i] += 1
if P > 1:
    F[P] = 1

ans = 1
for p in F.keys():
    ans *= p ** (F[p] // N)
print(ans)

Submission status: Accepted

Solution code:
import math
n,p=map(int,input().split(' '))
k=0
dio=math.sqrt(p)
jo=2
maxn=1
if n==1:
    print(p)
else:
    while jo<dio:
        if p%jo==0:
            p/=jo
            k+=1
            if k>=n:
                maxn*=jo
                k=0
        else:
            jo+=1
            k=0
    print(maxn)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import defaultdict
import math

def chai(a):
    ans = defaultdict(int)
    i = 2
    while i <= int(math.sqrt(a)):
        while a % i == 0:
            ans[i] += 1
            a //= i
        i += 1
    if a != 1:
        ans[a] += 1
    return ans
    
n, p = map(int, stdin.readline().strip().split())

tmp = chai(p)
ans = 1
for key, value in tmp.items():
    while value >= n:
        ans *= key
        value -= n
stdout.writelines(str(ans) + '\n')

Submission status: Accepted

Solution code:
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    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())
    arr = factorization(P)
    answer = 1
    for a in arr:
        if a[1] >= N:
            ans = a[0] ** (a[1] // N)
            answer *= ans
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

from collections import Counter
primes_counter = Counter(prime_factorize(p))

ans = 1
for kv in primes_counter.items():
  if kv[1] >= n: ans *= kv[0] ** (kv[1] // 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

N, P = map(int, input().split())
def prime_factorization(n):
    res = []
    for d in make_divisors(n):
        if d == 1:
            continue
        while n%d==0:
            res.append(d)
            n//=d
    return res

from collections import Counter
pc = Counter(prime_factorization(P))
ans = 1
for k, v in pc.items():
    loop = v//N
    if loop:
        ans *= k ** loop
print(ans)

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


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

Submission status: Accepted

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


def factorization(n):
    tmp = n
    d = {}
    for i in range(2, int(n ** 0.5) + 1):
        while tmp % i == 0:
            tmp //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1

    if tmp != 1:
        d[tmp] = 1

    return d


d = factorization(P)
ans = 1
for k, v in d.items():
    if v >= N:
        n = v // N
        ans *= k ** n

print(ans)

Submission status: Accepted

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


def factorization_in_prime_number(x):
    prime_factor = []
    degree = 0
    while x % 2 == 0:
        x //= 2
        degree += 1
    if degree:
        prime_factor.append((2, degree))
    m = int(x**.5) + 1
    for i in range(3, m, 2):
        degree = 0
        while x % i == 0:
            x //= i
            degree += 1
        if degree:
            prime_factor.append((i, degree))
    if x != 1:
        prime_factor.append((x, 1))
    return prime_factor


ans = 1
factor = factorization_in_prime_number(p)
for f, d in factor[::-1]:
    ans *= f ** (d//n)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
x = p
so = []
for i in range(2, int(p**(1/2))+1):
    c = 0
    while x%i==0:
        c += 1
        x //= i
    if c:
        so.append([c, i])
    if x==1:
        break
if x:
    so.append([1, x])
result = 1
for s, t in so:
    result *= t**(s//n)
print(result)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
x = p
so = []
for i in range(2, int(p**(1/2))+1):
    c = 0
    while x%i==0:
        c += 1
        x //= i
    if c:
        so.append([c, i])
if x:
    so.append([1, x])
result = 1
for s, t in so:
    result *= t**(s//n)
print(result)

Submission status: Accepted

Solution code:
import sys
from heapq import heappush, heappop, heappushpop, heapify, heapreplace
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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)
# print("a =", a)
ans = 1
for i in a:
    if i[1] >= n:
        ans *= i[0] ** (i[1] // n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

def factorization(n):
    factor = []
    tmp = int(n ** 0.5) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    factor.append(n)
    factor.sort()
    return factor

lP = factorization(P)
clP = Counter(lP)

ans = 1
for key in clP:
    if clP[key] >= N:
        ans *= key ** (clP[key] // N)
    # print(key, clP[key])

# print(N, lP)
print(ans)

Submission status: Accepted

Solution code:
#p=int(input())
n,p=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#素因数分解した結果を2次元配列にして返す
def prime_factorize(n):
    n_origin=n+0
    primelist=[]
    a=2
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist
pfs=prime_factorize(p)
ans=1

for pf in pfs:
    p=pf[0];ex=pf[1]
    ans=ans*(p**(ex//n))
print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(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 is_prime


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 //= i
        res.append((i, ex))
    if n != 1: res.append((n, 1))
    return res

N,P = imn()

pf = prime_factorize(P)

ans = 1
for p in pf:
    for i in range(p[1]//N):
        ans *= p[0]
print(ans)

Submission status: Accepted

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

#素因数分解した結果を2次元配列にして返す
def prime_factorize(n):
    primelist=[]
    a=2
    n_origin=n
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist

pfs=prime_factorize(p)
ans=1
for i in range(len(pfs)):
    prime=pfs[i][0]
    ex=pfs[i][1]
    val=ex//n
    ans=ans*(prime**val)
print(ans)

Submission status: Accepted

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

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

res = 1
for i in prime_division(p):
    a = i[1] // n
    res *= i[0] ** a
print(res)

Submission status: Accepted

Solution code:
from collections import Counter


def calc_prime_factors(n, count=False):
    """Trial division"""
    factors = []
    # factor: 2
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    # factor: 3, 5, 7, 11, ...
    f = 3
    while f ** 2 <= n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        factors.append(n)
    if count:
        factors = Counter(factors).items()
    return factors


N, P = map(int, input().split())
factors = calc_prime_factors(P, count=True)
ans = 1
for factor in factors:
    p, cnt = factor
    q, _ = divmod(cnt, N)
    ans *= p**q
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return


#main
if __name__ == '__main__':
    solve()

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
p=factorization(P)
#print(p)
k=[]
ans=1
for i in range(len(p)):
    d=p[i][1]//N
    k.append(d)
for i in range(len(p)):
    ans*=pow(p[i][0],k[i])
print(ans)

Submission status: Accepted

Solution code:
x, y = 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

B = prime_factorize(y)

import collections
C = collections.Counter(B)

ans = 1

for i in C:
    if C[i] >= x:
        ans *= i ** (C[i]//x)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, P = map(int, input().split())
cnt = defaultdict(int)
for i in range(2, int(P**0.5)+1):
    while P % i == 0:
        cnt[i] += 1
        P //= i
if P > 1:
    cnt[P] += 1
ans = 1
for k in cnt.keys():
    if cnt[k] >= N:
        ans *= k**(cnt[k]//N)
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
import math
input = sys.stdin.readline


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, input().split())
prime_list = list(Counter(prime_decomposition(p)).items())
ans = 1
for i in range(len(prime_list)):
    cnt = math.floor(prime_list[i][1] / n)
    if cnt >= 1:
        ans *= prime_list[i][0] ** cnt
print(ans)

Submission status: Accepted

Solution code:
def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime

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


if n>50: print(1)
elif n==1: print(p)
else:
    prime=Sieve_of_Eratosthenes(int(p**(1/n)))
    ans=1
    for i in range(2,len(prime)):
        if prime[i]==False: continue
        tmp=0
        while p%i==0:
            p//=i
            tmp+=1
        for _ in range(tmp//n):
                ans*=i
    print(ans)

Submission status: Accepted

Solution code:
def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime

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


if n>50: print(1)
elif n==1: print(p)
else:
    prime=Sieve_of_Eratosthenes(int(p**(1/n)))
    ans=1
    for i in range(2,len(prime)):
        tmp=0
        while p%i==0:
            p//=i
            tmp+=1
        if tmp>=n:
            for _ in range(tmp//n):
                ans*=i
    print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter,mul
from fractions import gcd
from functools import reduce
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

#https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a

n,p=mii()

# N: 素因数分解する数
#リストで返す
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)

m=Counter(res)

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

print(ans)

Submission status: Accepted

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

def main():
    N,P = map(int,input().split())
    
    is_prime = [True for i in range(int(P**(1/2))+1)]
    is_prime[0] = is_prime[1] = False
    
    for i in range(2,int(P**(1/2)+1)):
        if not is_prime[i]:
            continue
        j = 2*i
        while j<=int(P**(1/2)):
            is_prime[j] = False
            j += i

    ans = 1
    for i in range(1,int(P**(1/2)+1)):
        count = 0
        if is_prime[i]:
            while P%i == 0:
                count += 1
                P//=i
            z = pow(i,count//N)
            ans *= z
    
    z = pow(P,1//N)
    print(ans*z)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
f = []
for i in range(1, int(p**0.5)+1):
        if p%i==0:
                f.append(i)
                f.append(p//i)
ans = 1
for i in f:
        if p%pow(i,n, 92709568269121)==0: ans = max(ans, i)
print(ans)

Submission status: Accepted

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


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

primes = prime_factorize(P)
ret = 1
for i, e in primes:
    ret *= i ** (e//N)

print(ret)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
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 = inputlist()
li = factorization(P)
ans = 1
n = len(li)
for i in range(n):
    k = li[i][1]
    ans *= max(1,li[i][0]**(k//N))
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
#素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
X = factorization(P)
ans = 1
for i in X:
    ans *= max(1,i[0]**(i[1]//N))
print(ans)

Submission status: Accepted

Solution code:
def prime_pair(n):
    pairs = {}
    tmp = n
    for i in range(2, n):
        if i * i > n:
            break
        if tmp % i != 0:
            continue
        ex = 0
        while tmp % i == 0:
            ex += 1
            tmp /= i
        pairs[i] = ex
    if tmp != 1:
        pairs[int(tmp)] = 1
    return pairs

N, P = list(map(int, input().split()))
ppp = prime_pair(P)

res = 1
for k in ppp.keys():
    cnt = ppp[k]//N 
    
    if cnt>= 1:
        res *= k**cnt
print(res)

Submission status: Accepted

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

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

ans = 1
for p in res:
    k = p[1]
    while k:
        if k < n:
            k = 0
        else:
            ans *= p[0]
            k -= n
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    number, product = map(int, input().split())
    prime_factors = []
    while product % 2 == 0:
        prime_factors.append(2)
        product //= 2
    i = 3
    while i * i <= product:
        if product % i == 0:
            product //= i
            prime_factors.append(i)
        else:
            i += 2
    if product != 1:
        prime_factors.append(product)
    prime_factors = Counter(prime_factors)
    answer = 1
    for p, n in prime_factors.items():
        if number <= n:
            answer *= pow(p, n // number)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
  n, m = input_list()
  p = prime_factorize(m)
  pc = collections.Counter(p)
  ans = 1
  for k, v in pc.items():
    if v >= n:
      ans *= k ** (v//n)
  print(ans)
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
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

import math
import fractions
import collections
from functools import reduce
main()

Submission status: Accepted

Solution code:
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(not arr):
        arr.append([1,1])
    if(temp!=1):
        arr.append([temp,1])
    return arr

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

Submission status: Accepted

Solution code:
def f(k,n):

    r=1
    t = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if t%i==0:
            c=0
            while t%i==0:
                c+=1
                t //= i
            if c>=k:
                r*=i**(c//k)
    if k==1 and t!=1:r*=t
    if r==k==1:r*=n
    print(r)

f(*map(int,input().split()))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math
n,p = map(int,input().split())
ans = 1
if n == 1:
    print(p)
    exit()
for i in range(2,1+math.ceil(p**(1/2))):
    cnt = 0
    while p % i == 0:
        p = p//i
        cnt += 1
    beki = cnt // n
    ans *= pow(i,beki)
    #print(ans,i,cnt)
print(ans)