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:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


MOD = int(1e09) + 7
INF = int(1e15)


def factorization(n):
    S = {}
    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
            S[i] = cnt

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

    if S == []:
        S[n] = 1

    return S


def main():
    # sys.stdin = open("sample.txt")
    N, P = Scanner.map_int()
    S = factorization(P)
    ans = 1
    for k, v in S.items():
        if v >= N:
            ans *= k ** (v // N)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from math import log
def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
    else:
        ans = 1
        if n > int(log(p, 2))+2:
            print("1")
            sys.exit()
        if p % (2**n) == 0:
            while p % (2**n) == 0:
                ans *= 2
                p //= (2**n)
        for i in range(3, 10**6+1, 2):
            while p % (i**n) == 0:
                ans *= i
                p //= (i**n)
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,p=map(int,input().split())
def fact(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=fact(p)
t=1
for i in l:
  t=t*(i[0]**(i[1]//n))
print(t)

Submission status: Accepted

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

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs
    divs = trial_division(P)
    divs.sort()
    ans = 1
    for d in divs[1:]:
        # print(d, d**N, d**N <= P, P / d**N)
        # print(d)
        cur = 1
        for i in range(N):
            cur *= d
            if P < cur:
                break
        if P < cur:
            break
        if P % (d**N) == 0:
            ans = d
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def factorization(n):
    retlist = []
    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
            retlist.append([i, cnt])

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

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

    return retlist

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

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

Submission status: Accepted

Solution code:
import math
def solve():
    N, P = map(int, input().split())
    fac = list(prime_factorize(P).items())
    res = 1
    for p in fac:
        for i in range(p[1] // N):
            res *= p[0]
    
    print(int(res))

def prime_factorize(n):
    prime_numbers = {}
    for p in range(2, int(math.sqrt(n)+1)):
        if n % p != 0:
            continue
        num = 0
        while n % p == 0:
            n /= p
            num += 1
        prime_numbers[p] = num

    if n != 1:
        prime_numbers[n] = 1
    return prime_numbers

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b==0:
            n = n//b
            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())
ans = 1
for prime,power in factorize(p):
    ans *= pow(prime,(power//n))
print(ans)

Submission status: Accepted

Solution code:
N, P=map(int,input().split())
def factorization(n):
  primen = []
  degree = []
  primend = []
  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
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend

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

Submission status: Accepted

Solution code:
from collections import defaultdict

def prime(k):
    res=[]
    while k>1:
        count=2
        flag=False
        while count*count <= k:
            if k%count==0:
                res.append(count)
                k//=count
                flag=True
                break
            count+=1
        if not(flag):
            res.append(k)
            k=1
    return res

n,p=map(int,input().split())
d=defaultdict(int)
for z in prime(p):
    d[z]+=1

ans=1

for c,x in d.items():
    ans*=c**(x//n)
if n==1:
    print(p)
else:
    print(ans)

Submission status: Accepted

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

def factorize(n):
    from collections import defaultdict
    d = defaultdict(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    if n>1:
        d[n] += 1
    return d

d = factorize(P)
ans = 1
for i, j in d.items():
    ans *= (i ** (j//N))
print(ans)

Submission status: Accepted

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

def factorize(n):
    from collections import defaultdict
    d = defaultdict(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    return d

d = factorize(P)
ans = 1
for i, j in d.items():
    ans *= (i ** (j//N))
print(ans if N!=1 else P)

Submission status: Accepted

Solution code:
def prime_factors(N):
    from collections import defaultdict
    factors = defaultdict(int)
    for i in range(2,int(N**.5)+1):
        while N % i == 0:
            N //= i
            factors[i] += 1
    if N > 1:
        factors[N] += 1
    return dict(factors)

N,P=map(int, input().split())
factors=prime_factors(P)
ans=1
for k,v in factors.items():
    ans*=k**(v//N)
print(ans)

Submission status: Accepted

Solution code:
from math import sqrt, ceil, log2
n, p = map(int, input().split())
if n == 1:
    print(p)
elif n >= 40:
    print(1)
else:
    ret = 1
    for i in range(2, ceil(sqrt(p)) + 1):
        if p % (i ** n) == 0:
            ret = i
    print(ret)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, P: int):
    def primeFactorize(n: int):
        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

    # print(primeFactorize(P))
    from collections import Counter
    c = Counter(primeFactorize(P))

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


    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(N, P)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

n,p=map(int,input().split())
fcr=factorization(p)
ans=1
for i in set(fcr):
  if fcr.count(i)//n>=1:
    ans*=i**(fcr.count(i)//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

def prime_decomposition(n):
    table = []
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            n /= i
            table.append(i)
    if n>1:
        table.append(int(n))
    table = sorted(table, reverse=False)
    return table

lst = prime_decomposition(p)
c = dict(Counter(lst))

ans = 1
for k,v in c.items():
    if v >= n:
        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())
p_fact = factorization(P)
p_list = []
ans = 1
for p in p_fact:
    p[1] = p[1] // N
    p_list.append(p)

for p in p_list:
    ans = ans * pow(p[0], p[1])

print(ans)

Submission status: Accepted

Solution code:
n,p = map(int, input().split( ))
f = {}
for i in range(2,int(p**(1/2))+7):
    cnt = 0
    while (not p%i) and p>=i:
        cnt += 1
        p//=i
    if cnt:
        f[i]= cnt
if p>1:###
    f[p] = 1
ans = 1
for i in f:
    ans *= pow(i,f[i]//n)
print(ans)

Submission status: Accepted

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

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

from collections import Counter

ctr = Counter(prime_factorize(p))

for k, v in ctr.items():
    ctr[k] = v // n

ans = 1
for k, v in ctr.items():
    ans *= k ** v
print(ans)

Submission status: Accepted

Solution code:
import math
N, P = map(int, input().split())
D = {}
sqrt_p = int(math.sqrt(P))
for i in range(2, sqrt_p + 2):
    while P % i == 0:
        if i not in D:
            D[i] = 1
        else:
            D[i] += 1
        P //= i
if P != 1:
    if P not in D:
        D[P] = 1
    else:
        D[P] += 1

# print(D)
ans = 1
for d in D:
    if D[d] >= N:
        ans *= (d ** (D[d] // N))
print(ans)

Submission status: Accepted

Solution code:
from copy import deepcopy
from functools import reduce


class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n
            complexity: O(n^(1/2))
            used in ProjectEuler No.12, yukicoder No.36
        """
        assert(n >= 1)
        number = n
        if number == 1:
            self.primeFactorization = {1: 1}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if number > 1:
                self.primeFactorization[number] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])


def main() -> None:
    N, P = map(int, input().split())
    d = Divisor(P)
    ans = 1
    for key, value in d.primeFactorization.items():
        ans *= key ** (value // N)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby
n,p = [int(x) for x in stdin.readline().rstrip().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
li = prime_factorize(p)
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))
point = 1
for i in lin:
    if i[1] >= n:
        point *= i[0]**(i[1]//n)
print(point)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr


N, P = map(int, input().split())
prime_factors = factorization(P)
g = 1
for p in prime_factors:
    g *= p[0] ** (p[1] // N)
print(g)

Submission status: Accepted

Solution code:
def factorize(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N, P = map(int, input().split())
ans = 1
for p, e in factorize(P):
    if e >= N:
        ans *= p ** (e // N)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def factorize(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N, P = map(int, input().split())
d = defaultdict(int)
for p, e in factorize(P):
    if e >= N:
        d[p] = e // N
ans = 1
for p, e in d.items():
    ans *= p ** e
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.items():
  if n<=v:
    ans *= k**(v//n)
print(ans)

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)
i = 2
while P >= i*i:
    if P%i==0:
        P //= i
        d[i] += 1
    elif i == 2:
        i += 1
    else:
        i += 2
if P != 1:
    d[P] += 1

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

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)
i = 2
while P >= i*i:
    if P%i==0:
        P //= i
        d[i] += 1
    # elif i == 2:
    #     i += 1
    else:
        i += 1
        # i += 2
if P != 1:
    d[P] += 1

ans = 1
for k, v in d.items():
    # print(k, v)
    z = v // N
    ans *= k**z
print(ans)

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)
i = 2
while P >= i*i:
    if P%i==0:
        P //= i
        d[i] += 1
    elif i == 2:
        i += 1
    else:
        i += 2
if P != 1:
    d[P] += 1

ans = 1
for k, v in d.items():
    # print(k, v)
    z = v // N
    ans *= k**z
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


ans = 1
for i in Counter(prime_factorize(p)).most_common():
    if i[1] < n:
        break
    ans *= i[0]**(i[1]//n)
print(ans)

Submission status: Accepted

Solution code:
import math
n, p = map(int, input().split())
a = []
if n == 1:
  print(p)
  exit()
for i in range(2, math.ceil(p**0.5)+1):
  cnt = 0
  while p % i == 0:
    cnt += 1
    p //= i
  a.append(cnt)
gcd = 1
for i in range(len(a)):
  if a[i] >= n:
    gcd *= (i+2) ** (a[i] // n)
print(gcd)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
if n == 1:
    print(p)
    exit()
l = []
i = 2
while p > 1:
    if p % i == 0:
        p //= i
        l.append(i)
    else:
        i += 1
        if i > p ** (1/2):
            break
        
ans = 1

for i in set(l):
    m = l.count(i)
    if n <= m:
        ans *= i ** (m // n)

print(ans)

Submission status: Accepted

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

def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

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

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

  return arr

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

Submission status: Accepted

Solution code:
# coding: utf-8
def prime_factorization(N):
    # 辞書型で素因数分解を返す
    pf = {}
    for i in range(2, int(N**0.5) + 1):
        while N % i == 0:
            if i not in pf.keys():
                pf[i] = 1
            else:
                pf[i] += 1
            N //= i
    if N > 1:
        pf[N] = 1
    return pf

N, P = map(int, input().split())
pf = prime_factorization(P)
ans = 1
for k in pf.keys():
    ans *= k ** (pf[k] // N)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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


def prime_factorize(n):
    a = [1]
    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


d = Counter(prime_factorize(P))
answer = 1
for i, n in d.items():
    answer *= i ** (n // N)

print(answer)

Submission status: Accepted

Solution code:
from collections import Counter

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


def prime_factorize(n):
    a = [1]
    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


d = Counter(prime_factorize(P))
answer = 1
for i, n in d.items():
    if n >= N:
        answer *= i ** (n // N)

print(answer)

Submission status: Accepted

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

if n == 1:
    print(p)

else:
    factors = {}
    for i in range(2, int(p**0.5)+1):
        cnt = 0
        while p % i == 0:
            cnt += 1
            factors[i] = cnt
            p //= i

    if factors == {}:
        factors[p] = 1

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

    print(ans)

Submission status: Accepted

Solution code:
def prime_decomposition(n) -> 'List[Tuple[prime,cnt]]':
    ret = []

    x = n

    divisor = 2
    cnt = 0
    while x % divisor == 0:
        x //= divisor
        cnt += 1
    if cnt > 0:
        ret.append((divisor, cnt))

    divisor = 3
    while divisor * divisor <= n:
        cnt = 0
        while x % divisor == 0:
            x //= divisor
            cnt += 1
        if cnt > 0:
            ret.append((divisor, cnt))
        divisor += 2

    if x > 1:
        ret.append((x, 1))

    return ret


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

lis = prime_decomposition(p)

ret = 1
for pr, cnt in lis:
    ret *= pr ** (cnt // n)
print(ret)

#     if cnt >= n:
#         ret *= pr
# ではなく、cnt//n

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr


N, P = map(int, input().split())
ans = 1
# print(factorization(P))
for insi, num in factorization(P):
    if num >= N:
        ans *= (insi ** (num // N))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d={}
x=p
for i in range(2,p):
  while x%i==0:
    if i in d:
      d[i]+=1
    else:
      d[i]=1
    x//=i
  if i*i>=p:
    break
if x>1:
  d[x]=1

ans=1
for k,v in d.items():
  for i in range(v//n):
    ans*=k

print(ans)

Submission status: Accepted

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


div = {}
x = P
y = 2
while y*y <= x:
    while x % y == 0:
        try:
            div[y] += 1
        except KeyError:
            div[y] = 1
        x //= y
    y += 1
if x > 1:
    div[x] = 1

res = 1
for k, v in div.items():
    res *= k**(v//N)
print(res)

Submission status: Accepted

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

import math
import heapq
import sys
def judge_p(n):
	d = math.floor(n**(1/2))
	for i in range(2,d+1):
		if n%i == 0:
			return False
	return True

if n == 1:
	print(m)
	sys.exit()
if judge_p(m):
	print(1)
	sys.exit()

P = []
D = math.floor(m**(1/2))

for j in range(2,D+1):
	if judge_p(j):
		P.append(j)

deck = []

for prime in P:
	cnt = 0
	tmp = m
	while True:
		if tmp % prime == 0:
			cnt += 1
			tmp //= prime
		else:
			break
	deck.append([prime, cnt])

ans = 1
for i in range(len(deck)):
	prime, cnt = deck[i]
	if cnt//n == 0:
		continue
	ans *= prime**(cnt//n)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

import math
import collections


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(N: int, P: int):
    counter = factorial(P)
    ans = 1
    for k in counter:
        if counter[k] >= N:
            ans *= k**(counter[k]//N)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(N, P)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
from collections import defaultdict
elem = defaultdict(int)
tmpP = P
from math import sqrt
for i in range(2,int(sqrt(P))+1):
    while tmpP % i == 0:
        elem[i] += 1
        tmpP = tmpP//i
ans = 1
for k,v in elem.items():
    ans = ans * k ** (v//N)
if N == 1: ans = P
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

def Primefac(N):
    x = []
    while N % 2 == 0:
        N //= 2
        x.append(2)     
    i = 3
    while i * i <= N:
        if N % i == 0:
            N //= i
            x.append(i)
        else:
            i += 2
    if N != 1:
        x.append(N)
    return x

a = list(Counter(Primefac(P)).items())

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

Submission status: Accepted

Solution code:
def primes(n):
  ps = {}
  while n%2==0:
    n//=2
    if 2 not in ps:
      ps[2] = 1
    else:
      ps[2] += 1
  
  for i in range(3,int(n**.5)+1,2):
    while n%i==0:
      n//=i
      if i not in ps:
        ps[i] = 1
      else:
        ps[i] += 1
  
  if n!=1:
    ps[n] = 1
  
  return ps
  
N,P = map(int,input().split())
if N==1:
  print(P)
  exit()
ps = primes(P)
ans = 1
for p, num in ps.items():
  if num>=N:
    ans *= p**(num//N)
print(ans)

Submission status: Accepted

Solution code:
# C - Product and GCD
def factorization(n):
    """
    引数の値を素因数分解したリストを返す

    Parameters
    ----------
    n : int
        素因数分解したい自然数

    Returns
    -------
    retlist : list
        2以上の整数n => [[素因数, 指数], ...]の2次元リスト
    """
    retlist = []
    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
            retlist.append([i, cnt])

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

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

    return retlist

n,p=map(int,input().split())
l=[]
ans=1
l=factorization(p)
for ll in l:
    if ll[1]>=n:
        ans*=ll[0]**(ll[1]//n)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


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())
    p = prime_factorize(P)
    import collections
    ans = 1
    for k, v in collections.Counter(p).most_common():
        while v >= N:
            ans *= k
            v -= N
    print(ans)


if __name__ == '__main__':
    main()

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
b = collections.Counter(prime_factorize(p))
x = 1
for i,j in b.items():
	if j >= n:
		x *= i**(j//n)
if n == 1:
	print (p)
else:
	print (x)

Submission status: Accepted

Solution code:
import math
n, p = map(int, input().split())
ans = 1
for i in range(2, math.ceil(math.sqrt(p))):
    cnt = 0
    while p % i == 0 and p != 0:
        p //= i
        cnt += 1
    ans *= i ** (cnt // n)
ans *= p ** (1 // n)
print(ans)

Submission status: Accepted

Solution code:
import math
n, p = map(int, input().split())
cnt = [0] * math.ceil(math.sqrt(p))
tmp = p
for i in range(2, math.ceil(math.sqrt(p))):
    while p % i == 0 and p != 0:
        p //= i
        cnt[i] += 1
ans = 1
for i in range(2, math.ceil(math.sqrt(tmp))):
    ans *= i ** (cnt[i] // n)
ans *= p ** (1 // n)
print(ans)

Submission status: Accepted

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    # arr.append([n, 1])

    return arr

l = factorization(P)[::-1]

# print(l)

ans = 1
for n, k in l:
    if k >= N:
        ans *= n ** (k // N)

print(ans)