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:
n, p = map(int, raw_input().split())
fac = {}
primes = [1]*(10**6 + 200)
i = 2
prim = []
while i <= 10**6 + 100:
    if primes[i]:
        prim.append(i)
        j = i*2
        while j <= 10**6 + 100:
            primes[j] = 0
            j += i 
    i += 1 
for i in prim:
    while p%i == 0:
        p /= i 
        fac[i] = fac[i] + 1 if i in fac else 1
if p > 1:
    fac[p] = 1
ans = 1
for i in fac:
    if fac[i] >= n:
        ans *= i**(fac[i]/n)
print ans

Submission status: Accepted

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

def prf(m):
    pf = {}
    for i in range(2, int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i, 0)+1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf

pf = prf(p)
ans = 1

for i in pf:
    while pf[i] >= n:
        ans *= i
        pf[i] -= n
        
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int,input().split())
 
output=1
 
if P==1:
  output=1
elif N==1:
  output=P
else:
  for num in range(2,round(P**(1/N))+1):
    if P%(num**N) == 0:
      output = num
 
print(output)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 31 14:30:45 2018

@author: Yamazaki Kenichi
"""

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

limit = int(pow(P,1/N)//1)

if N == 1:
    ans = P
elif limit == 1:
    ans = 1
else:
    ans = 1
    for i in range(2,limit+2):
        if P % pow(i,N) == 0:
            ans = i
            
print(ans)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
    N, P = map(int, input().split())
    prime_factors = prime_factorize(P)

    gcd = 1
    for k, v in prime_factors.items():
        v_cnt = v // N
        gcd *= pow(k, v_cnt)

    print(gcd)
    return

main()

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

def is_prime(n: int)-> bool:
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    # when n is a prime number
    # x^(n-1) ≡ 1 (mod n)
    return pow(2, (n-1), n) == 1


def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime(i):
            continue
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
    N, P = map(int, input().split())
    prime_factors = prime_factorize(P)

    gcd = 1
    for k, v in prime_factors.items():
        v_cnt = v // N
        gcd *= pow(k, v_cnt)

    print(gcd)
    return

main()

Submission status: Accepted

Solution code:
import collections
import math

n, p = [int(i) for i in input().split()]
d = collections.defaultdict(lambda: 0)

def bunkai(q):
	if q == 1:
		return 0
	for i in range(2, math.ceil(math.sqrt(p))):
		if q % i == 0:
			d[i] += 1
			return bunkai(q//i)

if n == 1 or p == 1:
	print(p)
else:
	bunkai(p)
	ans = 1

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

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i<=(P**(1.001/N)):
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i<=(P**(1.05/N)):
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i<=(P**(2/N)):
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i**N<=P:
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40 or p==1:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)
 
    elif i==2:
      i+=1
    else:
      i+=2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1|N>=40:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
  exit()
elif P == 1:
  print(1)
  exit()
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Submission status: Accepted

Solution code:
def isprime(n):
    if(n==2 or n==3):
        return True
    if(n<=1):
        return False
    if(n%2==0 or n%3==0):
        return False
    x=5
    while(x*x<=n):
        if(n%x==0 or n%(x+2)==0):
            return False
        x+=6
    return True
n,p=map(int,input().split())
if(n==1):
    print(p)
else:
    ans=1
    for i in range(2,int(p**0.5)+1,1):
        num=p
        count=0
        while(num%i==0):
            num=num//i
            count+=1
        if(count>=n):
            ans=i
    print(ans)

Submission status: Accepted

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

if p == 1:
    print(1)
elif n == 1:
    print(p)
else:
    for i in range(round(p**(1/n)), 0, -1):
        if p % i**n == 0:
            print(i)
            break

Submission status: Accepted

Solution code:
n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import sys
import math
import random


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


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

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

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

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

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

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


prime = Prime()
factors = prime.find_factors(P)

GCD = 1

for k, v in factors.items():
    GCD *= k ** (v // N)

print(GCD)

Submission status: Accepted

Solution code:
import sys
import math
import random


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


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

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

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

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

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

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


prime = Prime()
factors = prime.find_factors(P)

GCD = 1

for k, v in factors.items():
    if v >= N:
        GCD *= k ** (v // N)

print(GCD)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
N, P = map(int, input().split())
if N == 1:
  print(P)
  exit()
if N > 40:
  print(1)
  exit()
res = []
for i in range(1,P+1):
  x = i**N
  if i**N > P:
    break
  if P%x == 0:
    res.append(i)
print(max(res))

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  CADDi2018 for Beginners C
#  https://atcoder.jp/contests/caddi2018b/tasks/caddi2018_a

def getMaxGCD(count,product):
	# getPrimeFunction
	primeSet = []  # リストの初期化
	maxCheckNumber = round(product ** (1 / 2))
	checkRange = range(2, maxCheckNumber + 1, 1)
	for i in checkRange:
		baseCount = 0
		while product % i == 0:
			baseCount = baseCount + 1
			product = product // i
		if  0 < baseCount:
			primeSet.append((i, baseCount))
# 二つを引数にしそれぞれ出力する
	if 1 < product:
		primeSet.append((product, 1))

	gcdNumber = 1
	for baseCount,powNumber in  primeSet:
		gcdNumber = gcdNumber * (baseCount ** ( powNumber // count))
	return gcdNumber

if __name__ == '__main__':
	n , p  = map(int,input().strip().split(' '))
	if n == 1:
		print(p)
		exit(0)
	if p == 1:
		print(1)
		exit(0)
	solution=getMaxGCD(n,p)
	print('{}'.format(solution))

Submission status: Accepted

Solution code:
def abc(n,p):
    ans=1
    b = 2
    if n==1:
        return p
    e=0
    while p%b == 0:
        p = p//b
        e +=1
    e=int(e//n)
    if e:
        ans*=(b**e)
    b+=1
    while b**2<=p:
        e=0
        while p%b == 0:
            p = p//b
            e +=1
        e=int(e//n)
        if e:
            ans*=(b**e)
        b+=2
    return ans

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

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

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

fact = factorize(P)

ans = 1
for f,n in fact:
    ans *= f**(n//N)

print(ans)

Submission status: Accepted

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

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors

fs = Counter(prime_factors(P))

d = 1
for k, c in fs.most_common():
    if c >= N:
        for _ in range(int(c/N)):
            d *= k
print(d)

Submission status: Accepted

Solution code:
from math import sqrt
from collections import defaultdict
n,p = (int(i) for i in input().split())
d,ans = defaultdict(int),1
while 1:
	f = p
	for i in range(2,int(sqrt(p))+1):
		if p%i==0:
			d[i]+=1
			p//=i
			break
	if f==p:
		d[p]+=1
		break
for i,j in d.items(): ans*=i**(j//n)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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


input = sys.stdin.readline
N, P = map(int, input().split())
c = 1
for b, e in factorize(P):
    c *= b ** (e // N)
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
N,P=map(int,raw_input().split())

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

Soin_s=collections.Counter(Soin)

Ans=1
for s in Soin_s:
    if Soin_s[s]>=N:
        Ans=Ans*(s**(Soin_s[s]/N))
print Ans

Submission status: Accepted

Solution code:
n,p = map(int,input().split())
a = []
i = 2
k = p

if n == 1:
  c = p
else:
  while (p>1) and (i < int(k**0.5) + 4):
      c = 0
      while p%i == 0:
          p = p/i
          c += 1
      a.append([i,c])
      i += 1
  if p>1:
      a.append([p,1])
  c = 1

  for i in range(len(a)):
    if a[i][1] >= n:
      k = a[i][0] ** int(a[i][1]/n)
      c = c* k

print(c)

Submission status: Accepted

Solution code:
import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)
N,P = map(int,input().split())
result = factoring(P)
ans = 1
for e in result:
  ans *= pow(e[0],e[1] // N)
print(ans)

Submission status: Accepted

Solution code:
import math
N,P = map(int,input().split())
if N == 1:
    print(P)
    exit()
ans = 1
for i in range(2,math.floor(pow(P,1/2)) + 1):
    if P % i == 0:
        count = 1
        P = P // i
        while P % i == 0:
            count += 1
            P = P // i
        ans *= pow(i,count // N)
print(ans)

Submission status: Accepted

Solution code:
n, p = map(int, input().split())
if n == 1:
  print(p)
  exit()
ans = 1
for i in range(2, 1+int(p**(1/n))):
  count = 0
  while True:
    if p % i ==0:
      count += 1
      p = p / i
    else:
      ans*= i**(count//n)
      break
print(ans)

Submission status: Accepted

Solution code:
def pd(x):
  i = 2
  table = []
  while i * i <= x:
    while x % i == 0:
      x //= i
      table.append(i)
    i += 1
  if x > 1:
    table.append(x)
  return table

n,p=map(int,input().split())
if n==1 or p==1:
    print(p)
    exit()
l=pd(p)
ans=1
r={}
for i in l:
    while p%i==0:
        if i in r: r[i]+=1
        else: r[i]=1
        p//=i
    if i>=p: break
for i in r:
    #if (r[i]//n)>0: ans*=i*(r[i]//n)
    if (r[i]//n)>0: ans*=(i**(r[i]//n))
print(ans)

Submission status: Accepted

Solution code:
N,P = map(int,input().split())
# def usage(N):
    # n = N

    # print('# 素因数')
    # fct = factorize(n)
    # print(fct, num(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

cnt = 1

for (x,y) in factorize(P):
    cnt = cnt * x**(y // N)

print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
    
from sys import stdin
    
n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1
    
def devide_counter(x, p):
    count = 1
    x = x // p
    while x % p == 0:
        count += 1
        x = x // p
    return x, count
    
def factorize(x):
    ans = 1
    
    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))
    
    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans
    
if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        count = 1
        x /= p
        while x % p == 0:
            count += 1
            x /= p
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            count = 1
            x /= p
            while x % p == 0:
                count += 1
                x /= p
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def devide_counter(x, p):
    count = 1
    x /= p
    while x % p == 0:
        count += 1
        x /= p
    return x, count

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def prime_factorize_fast(n, res=Counter()):
    while n % 2 == 0:
        res[2] += 1
        n //= 2
    while n % 3 == 0:
        res[3] += 1
        n //= 3
    d = 5
    step = 2
    while d <= int(n ** .5):
        while n % d == 0:
            res[d] += 1
            n //= d
        d += step
        step = 6 - step
    if n != 1:
        res[n] += 1
    return res

N, P = map(int, input().split())
cnt = prime_factorize_fast(P)
ans = 1
for f in cnt:
    if cnt[f] >= N:
        ans *= f ** (cnt[f] // N)
print(ans)

Submission status: Accepted

Solution code:
n, p = [int(i) for i in input().split()]
if n >= 40:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Submission status: Accepted

Solution code:
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Submission status: Accepted

Solution code:
N, P = map(int, raw_input().split())
max_N = 40
if N == 1:
    print P
elif N >= max_N:
    print 1
else:
    res = 1
    i = 2
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res

Submission status: Accepted

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

p2 = round(p ** (1 / n))

for i in range(p2, 0, -1):
    if p % (i ** n) == 0:
        print(i)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import math

N, P = map(int, input().split())
ans = 1
target = 2
sum = {}

if N == 1:
    ans = P
else:
	while True:
	    if P % target == 0:
	        if target in sum:
	            sum[target] += 1
	        else:
	            sum[target] = 1
	        P /= target
	        target = 2
	    else:
	        target += 1
	    if math.sqrt(P) < target:
	        P = int(P)
	        if P in sum:
	            sum[P] += 1
	        else:
	            sum[P] = 1
	        break
	for fact in sum:
	    # print("{} {}".format(fact, sum[fact]))
	    while sum[fact] >= N:
	        sum[fact] -= N
	        ans *= fact

print("{}".format(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import math

N, P = map(int, input().split())
ans = 1
target = 2
sum = {}

while True:
    if P % target == 0:
        if target in sum:
            sum[target] += 1
        else:
            sum[target] = 1
        P /= target
        target = 2
    else:
        target += 1
    if math.sqrt(P) < target:
        P = int(P)
        if P in sum:
            sum[P] += 1
        else:
            sum[P] = 1
        break

for fact in sum:
    # print("{} {}".format(fact, sum[fact]))
    while sum[fact] >= N:
        sum[fact] -= N
        ans *= fact

print("{}".format(ans))

Submission status: Accepted

Solution code:
import math


def get_max(n, p):
    factors = []
    counts = []

    count = 0
    while p % 2 == 0:
        count += 1
        p = p / 2

    if count > 0:
        factors.append(2)
        counts.append(count)

    for i in xrange(3, int(math.sqrt(p)) + 1, 2):
        # print i

        count = 0
        while p % i == 0:
            count += 1
            p = p / i

        if count > 0:
            factors.append(i)
            counts.append(count)

    if p > 2:
        factors.append(p)
        counts.append(1)

    if len(factors) == 0:
        return 1

    i = len(factors) - 1

    ans = 1

    while i >= 0:

        # print counts[i], n

        if counts[i] >= n:

            power = int(counts[i]/n)
            ans *= factors[i]**power

        i -= 1

    return ans

N, P = map(int, raw_input().split())
print get_max(N, P)

Submission status: Accepted

Solution code:
N, P = [int(i) for i in input().strip().split()]
dic={}
ans = 1

if N == 1:
    print(P)
    quit()
elif P == 1:
    print(1)
    quit()
    
for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = int(P/i)
    dic[i] = num//N
    ans = ans*(i**(dic[i]))

print(ans)

Submission status: Accepted

Solution code:
import collections
N,P = map(int,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
  
if __name__ == '__main__':

    lst = prime_decomposition(P)
    cout = collections.Counter(lst)
    ans = 1
    for p in cout.items():
        if p[1]>= N:
            ans = ans * (p[0] ** (p[1] // N))
    print(ans)