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 Counter

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

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

a = prime_factor(p)
a.append(1)
c = Counter(a)
d = c.most_common()

res = 1

for i in range(len(d)):
    if d[i][1] >= n:
        k = d[i][1]//n
        res = res * (d[i][0]**k)
        
        if i == len(d)-1:
            break
    else:
        break

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N, P = inpl()

def primes(N):
    sieve = [1] * (N+1)
    sieve[:2] = [0, 0]
    for i in range(N):
        if sieve[i]:
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

if N == 1:
    print(P)
else:
    ps = primes(10**6)
    
    ans = 1
    for p in ps:
        tmp = P * 1
        cnt = 0
        while tmp % p == 0:
            tmp = tmp // p
            cnt += 1
        ans *= p ** (cnt//N)
    
    print(ans)

Submission status: Accepted

Solution code:
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


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

res = 1
maxcnt = 0

for m, cnt in factorize(p):
    while cnt >= n:
        res *= m
        cnt -= n
        

print(res)

Submission status: Accepted

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

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

re = 1
if N == 1:
    re = P
else:

    f_list = factorize(P)

    for k, n in f_list:
        if n // N > 0:
            re *= k ** (n //N)
        
print(re)

Submission status: Accepted

Solution code:
# C
import numpy as np
N, P = map(int, input().split())

primes = np.ones(10**6)
primes[:2] = 0
for p in range(2, 10**3):
    if primes[p] == 1:
        primes[2*p::p] = 0

prim = np.where(primes == 1)[0]

if N == 1:
    res = P
    print(res)
else:
    res = 1
    for p in prim:
        k = 0
        while P % p == 0:
            k += 1
            P = P // p
        res *= p ** (k//N)
    print(res)

Submission status: Accepted

Solution code:
import collections
import math


def main():
    n, p = map(int, input().split())

    a = collections.defaultdict(lambda: 0)

    if n == 1:
        print(p)
        return

    for i in range(2, int(math.sqrt(p)) + 1):
        while p % i == 0:
            a[i] = a[i] + 1
            p //= i

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

    print(ret)


main()

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
# S = input()
#n = int(input())
N, P = map(int, input().split())
#a = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

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

ans = 1
innsuu = prime_factors(P)

innsuu.sort()

if (N == 1):
    print(P)
else:
    count = 1
    count_num = 0
    for i in innsuu:
        if (count_num == i):
            count += 1
        else:
            count_num = i
            count = 1

        if (count == N):
            ans *= count_num
            count = 1
            count_num = 0

    print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, P = map( int, input().split())
A = defaultdict( int)
S = set()
ans = 1
if N == 1:
    ans = P
else:
    T = P
    for i in range(2, int(P**(1/2)) + 1):
        while P%i == 0:
            P //= i
            S.add(i)
            A[i] += 1
    if T == P:
        A[T] += 1
        S.add(T)
    for s in S:
        if A[s] >= N:
            ans *= s**(A[s]//N)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,p = map(int, input().split())

# is_prime = list(range(n+1))
# is_prime[1] = 0
# for i in range(2,n+1):
#     if i*i>n+1:
#         break
#     if is_prime[i]:
#         for x in range(2*i,n+1,i):
#             is_prime[x] = 0
# primes = [p for p in is_prime if p!=0]

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

res = 1
for r in div.keys():
    while div[r]>=n:
        res *= r
        div[r] -= n

print(res)

Submission status: Accepted

Solution code:
def so(x, i):
  if x % i == 0:
    return 1 + so(x // i, i)
  else:
    return 0

n, p = map(int, input().split())
soinsu = {}
i = 2
while i * i <= p:
  if so(p, i) != 0:
    soinsu[i] = so(p, i)
    p //= i ** so(p, i)
  i += 1
if p > i:
  soinsu[p] = 1
r = 1
for k in soinsu:
  r *= k ** (soinsu[k] // n)

print(r)

Submission status: Accepted

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

ans = 1
if n == 1:
    ans = p
else:
    q = p
    for d in range(2, 1000001):
        if q < d**2:
            break
        cnt = 0
        while q % d == 0:
            q //= d
            cnt += 1
        ans *= d**(cnt // n)
print(ans)

Submission status: Accepted

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    P = int(buflist[1])
    factor = prime_factorization(P)
    max_gcd = 1
    for f, c in factor.items():
        while c >= N:
            max_gcd *= f
            c -= N
    print(max_gcd)

def prime_factorization(number):
    n = number
    i = 2
    factor = {}
    while i * i <= n:
        while n % i == 0:
            if i in factor:
                factor[i] += 1
            else:
                factor.update({i : 1})
            n //= i
        i += 1
    if n > 1 or not factor:
        if n in factor:
            factor[n] += 1
        else:
            factor.update({n : 1})
    return factor

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def fctr1(n): #[[素因数,数]]を出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f
a=fctr1(p)
ans=1
for i in range(len(a)):
    ans=ans*(a[i][0]**(a[i][1]//n))
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
from collections import defaultdict
import bisect

N, P = [int(x) for x in input().split()]


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


t = prime_decomposition(P)
c = collections.Counter(t)

ret = 1
for k,v in c.items():
    v2 = v
    while v2 >= N:
        ret *= k
        v2 -= N

print(ret)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d

n,p = li()

facs = factorize(p)

ans = 1
for k in sorted(facs.keys()):
    if facs[k] >= n:
        ans = ans * k**(facs[k]//n)
        
print(ans)

Submission status: Accepted

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

pl = []
d = {}

p = P
i = 2
while i * i <= P:
    cnt = 0
    while p % i == 0:
        p //= i
        cnt += 1
    if cnt > 0:
        d[i] = cnt
    i += 1

if p != 0:
    d[p] = 1

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

print(ans)

Submission status: Accepted

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

sqp = math.floor(math.sqrt(p)) + 1
if n == 1:
    print(p)
    sys.exit(0)
insu = {}
for i in range(2, sqp + 1):
    while p % i == 0:
        p //= i
        if i in insu:
            insu[i] += 1
        else:
            insu[i] = 1
ans = 1
for i in insu:
    while insu[i] >= n:
        insu[i] -= n
        ans *= i
print(ans)

Submission status: Accepted

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

sqrtp = int(math.sqrt(p))

b = []

for i in range(2, sqrtp+1):
    count = 0
    while p % i == 0:
        count += 1
        p = p // i
    b.append((i, count))
if p > 1:
    b.append((p, 1))

num = 1
for i, c in b:
    c = c // n
    if c > 0:
        num *= (i ** c)

print(num)

Submission status: Accepted

Solution code:
from math import floor, sqrt
from collections import Counter

def getPrimeFactor(x):
    ans = []
    for d in range(2, floor(sqrt(x)) + 1):
        while x % d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

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

PFs = getPrimeFactor(P)
cnt = Counter(PFs)

ans = 1
for p, num in cnt.items():
    if num // N:
        ans *= p ** (num // N)
print(ans)

Submission status: Accepted

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


import array
import collections
import math


def sieve_of_eratosthenes(end, typecode="L"):
    assert end > 1
    is_prime = array.array("B", (True for i in range(end)))
    is_prime[0] = False
    is_prime[1] = False
    primes = array.array(typecode)
    for i in range(2, end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes


def factorize_trial_division(n, typecode="Q"):
    factors = array.array(typecode)
    if n < 2:
        return factors
    for p in sieve_of_eratosthenes(math.ceil(math.sqrt(n)) + 1):
        if p * p > n:
            break
        while n % p == 0:
            factors.append(p)
            n //= p
    if n > 1:
        factors.append(n)
    return factors


def solve(n, p):
    factors_counter = collections.Counter(factorize_trial_division(p))
    res = 1
    for k, v in factors_counter.most_common():
        d = v // n
        if d == 0:
            break
        else:
            res *= k ** d
    return res


def main():
    n, p = (int(z) for z in input().split())
    print(solve(n, p))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

def usage(n):
    
    # print('# 素因数')
    fct = factorize(n)
    # print(fct, num(fct))
    return fct
    # print('# 約数')
    # for div in divisorize(fct):
    #     print(div, num(div))


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    N,P = map(int,input().split())
    fct = usage(P)
    ans = 1
    for i,j in fct:
        if j >= N:
            ans *= i**(j//N)
    print(ans)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
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
ans=1
for i in pf:
    if pf[i]>=n:
        ans*=i**(pf[i]//n)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def solve(n, p):
    if n == 1:
        return p
    i = 2
    ps = defaultdict(lambda: 0)
    while i * i <= p:
        while p % i == 0:
            p //= i
            ps[i] += 1
        i += 1
    ans = 1
    for p, c in ps.items():
        ans *= p ** (c // n)
    return ans


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

Submission status: Accepted

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

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

        rec.append((i, tmp))

if K != 1:
    rec.append((K, 1))

num = 1
for k, i in rec:
    q = i
    while q >= N:
        num *= k
        q -= N

print(num)

Submission status: Accepted

Solution code:
from collections import Counter
from math import sqrt

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

for i in range(2, int(sqrt(p))+1):
	while p % i == 0:
		c[i] += 1
		p = p // i
c[p] += 1

#print(c)
ans = 1
for key, value in c.items():
	if value >= n:
		ans *= key ** (value // n)

print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

factors = factorize(P)
ans = 1
for k,v in factors.items():
    a = v//N
    ans *= k**a
print(ans)

Submission status: Accepted

Solution code:


N, P = map(int, input().split())
if N==1:
    print(P)
    exit()
# 素因数分解
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
L = prime_decomposition(P)

cnt = 0
ans = 1
vp = 0
for v in L:
    if vp==v:
        cnt += 1
        if cnt == N:
            cnt = 0
            ans *= v
    else:
        cnt = 1
        vp = v
#print(L)
print(ans)

Submission status: Accepted

Solution code:
N,P=map(int,input().split())
D=dict()
k=2
Q=P
while(True):
    if k*k>P:
        break
    if Q%k==0:
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        Q=Q//k
    else:
        k+=1
if Q in D:
    D[Q]+=1
else:
    D[Q]=1
ans=1
for p in D:
    ans=ans*(p**(D[p]//N))
print(ans)

Submission status: Accepted

Solution code:
class Factorization:
  def __init__(self):
    self.F={}
    self.i=2
    self.c=0
    
  def factorint(self,x):
    while self.i**2<=x:
      if x%self.i==0:
        self.c=0
        while x%self.i==0:
          x=x//self.i
          self.c+=1
        self.F[self.i]=self.c
      self.i+=1
    if x!=1:
      self.F[x]=1
    return self.F
fac=Factorization()
N,P=map(int,input().split())
A=fac.factorint(P)
ans=1
for i,q in A.items():
  ans*=i**(q//N)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, raw_input().split())
if n == 1:
    print p
elif n > 40:
    print 1
else:
    ans = 1
    i = 2
    while 1:
        k = pow(i, n)
        if k > p:
            break
        while p % k == 0:
            ans *= i
            p /= k
        i += 1
    print ans

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import sqrt

n, p = [int(i) for i in input().split()]

A = defaultdict(int)

def factorize(n):    
    i = 2
    
    while n % i == 0:
        n //= i
        A[i] += 1
    i += 1

    while n != 1 and i <= sqrt(n):
        while n % i == 0:
            n //= i
            A[i] += 1
        i += 2
    if n != 1:
        A[n] += 1

    return A

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

print(ans)

Submission status: Accepted

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

# n以下の素数列を返す (eratostenes)
def prim(n):
    flg = [True for i in range(n+1)]
    flg[0] = False
    flg[1] = False
    sosuu = []
    for i in range(2,n+1):
        if flg[i]:
            sosuu.append(i)
            counter =2*i
            while counter <=n:
                flg[counter] = False
                counter += i
    return sosuu


# n の素因数分解 prim必要
    
def primdiv(n):
    """
    24 = 2^3 * 3^1
    primdiv(24) >> [[2, 3], [3, 1]]    
    """
    ans = []
    sosuu = prim(int(n**0.5)+1)
    for i in sosuu:
        if n%i == 0:
            counter = 1
            n = n//i 
            while n%i == 0:
                counter += 1
                n = n//i           
            ans.append([i,counter])
    if n != 1:
        ans.append([n,1])
    return ans

slis = primdiv(P)
ans = 1
for k in slis:
    ans *= k[0]**(k[1]//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()])


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

Submission status: Accepted

Solution code:
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, P = getIntList()
#print(N)
if N==1:
    print(P)
    sys.exit()
r = 1
for  t in range(2,1000003):
    if P%t!=0: continue
    c = 0
    while P%t==0:
        P//=t;
        c+=1
    r *= t ** (c//N)

print(r)

Submission status: Accepted

Solution code:
def process(n, p):
    foo = 1
    k = 2
    while k * k <= p:
        c = 0
        while p % k == 0:
            p /= k
            c += 1
        if c >= n:
            foo *= k ** (c / n)
        k += 1
    if n == 1:
        foo *= p
    return foo

def main():
    n, p = [int(i) for i in raw_input().strip().split()]
    print process(n, p)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [(2,2),(3,1)]
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
    return a


# 入力:整数n      ex)100
# 出力:約数リスト ex)[1, 5, 25, 2, 10, 50, 4, 20, 100]
def divisorEnumulation(n):
    divisor = []
    for div in divisorize(factorize(n)):
        divisor.append(num(div))
    return divisor


# 使用例
# print(divisorEnumulation(100))

n, p = [int(i) for i in input().split()]
fact = factorize(p)
out = 1
for i in range(len(fact)):
    out *= fact[i][0] ** (fact[i][1]//n)
print(out)

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

N, P = inpl()
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 i , v in pf.items():
    ans *=  i**(v//N)
print(ans)

Submission status: Accepted

Solution code:

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


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


fct = factorize(P)
ans = 1
for i,n in fct:
    ans *= i**(n//N)

print(ans)

Submission status: Accepted

Solution code:
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    mrFlg = 0
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    while i**2 <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        if i == 2:
            i = 3
        else:
            i += 2
        if i == 101 and n >= (2**20):
            def findFactorRho(N): # Primeでないことを確認したものを引数とする。
                def gcd(a, b):
                    if b == 0:
                        return a
                    else:
                        return gcd(b, a % b)
                def f(x, c):
                    return ((x ** 2) + c) % N
                semi = [N]
                for c in range(1, 11):
                    x=2
                    y=2
                    d=1
                    while d == 1:
                        x = f(x, c)
                        y = f(f(y, c), c)
                        d = gcd(abs(x-y), N)
                    if d != N:
                        if isPrimeMR(d):
                            return d
                        elif isPrimeMR(N//d):
                            return N//d
                        else:
                            semi.append(d)

                semi = list(set(semi))
                print (semi)
                s = min(semi)
                for i in [2,3,5,7]:
                    while True:
                        t = int(s**(1/i)+0.5)
                        if t**i == s:
                            s = t
                            if isPrimeMR(s):
                                return s
                        else:
                            break

                i = 3
                while True:
                    if s % i == 0:
                        return i
                    i += 2
                    
            while True:
                if isPrimeMR(n):
                    break
                else:
                    mrFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                        ret[j] = k
                if n == 1:
                    break
        
    if n > 1:
        ret[n] = 1
    if mrFlg > 0:
        def dict_sort(X):
            Y={}
            for x in sorted(X.keys()):
                Y[x] = X[x]
            return Y
        ret = dict_sort(ret)
    return ret

def isPrime(N):
    if N <= 1:
        return False
    return sum(primeFactor(N).values()) == 1

def isPrimeMR(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for a in [2, 3, 5, 7, 11, 13, 17, 19]:
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True        

def findPrime(N):
    if N < 0:
        return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

N, P = map(int, input().split())
tmp = primeFactor(P)
ans = 1
for t in tmp:
    ans *= t ** (tmp[t] // N)


print (ans)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
import math
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n //= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
so = factorization(p)
ans = 1
for i,j in so:
    ans *= i**(j//n)
print(ans)

Submission status: Accepted

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

import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

ANS=1
for j in FACT:
    ANS*=(j**(FACT[j]//N))

print(ANS)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
p_dict = {}
for num in range(int(P*0.5)+1):
  while P%num == 0:
    if num in p_dict:
      p_dict[num] += 1
    else:
      p_dict[num] = 1

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

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

MAX = int(P**0.5)+1
for p in range(2, MAX):
    while P % p == 0:
        dic[p] += 1
        P //= p
    if P:
        dic[P] += 1

ans = 1
print(dic)1
for p, cnt in dic.items():
    ans *= pow(p, cnt//N)
print(ans)

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())
for i in range(int(p**(1/n)+1)):
  if p%i**n==0:exit(print(i))

Submission status: Runtime Error

Solution code:
n,p= map(int, input().split())
ans=1
for i in range(2,p**(-n)):
  if p>i**n:
    if p%(i**n)==0:
      ans=i
  
print(ans)

Submission status: Runtime Error

Solution code:
n,p= map(int, input().split())
ans=0
for i in range(2,p**(-n+1)):
  if p%(i**n)==0:
    ans=i
  
print(ans)

Submission status: Runtime Error

Solution code:
from math import sqrt
from math import floor
n,p = map(int,input().split())
l = [p]
for i in range(2,floor(sqrt(p))+1):
    if p % i == 0:
        l.append(i)
        l.append(p//i)
l.sort()
s = []
i = 0
while p > 1:
    if p % l[i] == 0:
        s.append(l[i])
        p = p // l[i]
    else:
        i += 1
print(s[0]*s[-1])

Submission status: Runtime Error

Solution code:
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break
 
    if P != 1:
        prime.append([P, 1])
 
    return prime
 
def main2():
    N, P = map(int, input().split())
 
    prime = prime_factorize(P)
 
    print(prime)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 
 
    print(ans)
 
if __name__ == "__main__":
    main2()
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break

    if P != 1:
        prime.append([P, 1])

    return prime

def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Submission status: Runtime Error

Solution code:
import math
N,P=map(int,input().split())
i=math.ceil(P**(1/N))
while 1:
    if P%(i**N)==0:print(i);exit()
    i-=1

Submission status: Runtime Error

Solution code:
N,P=map(int,input().split())
i=1
while i**N<=P:
    if P%i**N==0:a=i
    i+=1
print(a)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
import sympy
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

tmp = factorization(p)
ans = 1
for i in range(len(tmp)):
    while tmp[i][1]>=n:
        tmp[i][1]-=n
        ans*=tmp[i][0]
print(ans)