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: Time Limit Exceeded

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

import math
import random

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):
        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):
        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):
        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):
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        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()

if __name__ == '__main__':
    prime = Prime()
    table = prime.find_factors(P)

c = 1
for k, v in table.items():
    d = v // N
    if d >= 1:
        c = c * (k ** d)
print(c)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

n,p = map(int,input().split())
d = []
res = 1

a = 2
while(1):
  if p % a**n == 0:
    p /= a**n
    res *= a
    continue
  a += 1
  if p == 1:
    break

print(res)

Submission status: Time Limit Exceeded

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


import random


def is_prime(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        #[0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


ans = 1
tmp = P
start = P // (2 ** N) + 1
# for i in range(start, 1, -1):
#     newtmp, rest = divmod(tmp, (i**N))
#     print(i, tmp, rest, ans)
#     if rest == 0:
#         ans = ans * i
#         tmp = newtmp

for i in range(2, P):
    if not is_prime(i):
        continue
    while True:
        rest = tmp % (i ** N)
        newtmp = tmp // (i ** N)
        # print(i, tmp, rest, ans)
        if rest == 0:
            ans = ans * i
            tmp = newtmp
        else:
            break
    if newtmp == 0:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

p = int(p) + 1

dic = {}

def my(N,p,s=2):
    for i in range(s,p+1):
        if p % i == 0:
            # print('ok')
            dic[i] = dic.get(i,0) + 1
            # print(dic)
            p = p//i
            s = i
            break
    
    if p == 1:
        res = 1
        for j,k in dic.items():
            res *= j**(k//N)
        print(res)
        exit()
    else:
        my(N,p,s)

my(N,P)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,P = map(int, input().split())
t=2
max=1
while(t**N<=P):
    if(P%(t**N)==0):
        max=t*max
        P=P/(t**N)
        t=1
    t=t+1
print(max)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(100000)
np=list(map(int,input().split()))
def gc(n,p,g):
    x = 0
    for i in range(2,int((p**(1/n))//1)+1):
        if p%(i**n) == 0:
            x=i
    if x == 0:
        return g
    else :
        return gc(n,p/(x**n),g*x)

#q = np[1]**(1/np[0])
#r = int(q//1)
s=gc(np[0],np[1],1)
print(s)

Submission status: Time Limit Exceeded

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

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

max1=1
max2=1

i=1
while P%((2**i)**N)==0:
    max1=2**i
    i+=1
P//=max1
end=int(P**(1/N))+1
for i in range(3,end+1,2):
    if P%(i**N)==0:
        if max2<i:
            max2=i
print(max1*max2)

Submission status: Time Limit Exceeded

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

if N==1:
    print(M)
else:
    ans=1
    for i in range(2,10**6+1):
        if M%(i**N)==0:
            ans=i
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
Pa = 1
Pb = P
gcd = 1
while Pa <= Pb:
    if P % Pa == 0:
        Pb = P // Pa
        if P % (Pa ** N) == 0:
            gcd = max(gcd, Pa)
        if P % (Pb ** N) == 0:
            gcd = max(gcd, Pb)
    Pa += 1
print(gcd)

Submission status: Time Limit Exceeded

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

now = 1

x = 2
while P >= x ** N:
    while P % (x ** N) == 0:
        now *= x
        P = P / (x ** N)
    while P % x == 0:
        P = P / x
    x += 1

print(now)

Submission status: Time Limit Exceeded

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


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

ans = 1
for i in range(2, p+1):
    power = i**n
    if p % power == 0:
        ans = i
    if power >= p:
        break
print(ans)

Submission status: Time Limit Exceeded

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


def is_prime(q):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    return pow(2, q - 1, q) == 1


ans = 1
tmp = P

for i in range(2, P):
    if not is_prime(i):
        continue
    while True:
        rest = tmp % (i ** N)
        newtmp = tmp // (i ** N)
        # print(i, tmp, rest, ans)
        if rest == 0:
            ans = ans * i
            tmp = newtmp
        else:
            break
    if newtmp == 0:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

p = int(p) + 1

dic = {}

def my(N,p):
    for i in range(2,p+1):
        if p % i == 0:
            # print('ok')
            dic[i] = dic.get(i,0) + 1
            # print(dic)
            break
    p = p//i
    if p == 1:
        res = 1
        for j,k in dic.items():
            res *= j**(k//N)
        print(res)
        exit()
    else:
        my(N,p)

my(N,P)

Submission status: Time Limit Exceeded

Solution code:
q = input().split()
n = int(q[0])
p = int(q[1])
m = 1
for i in range(int(p**(1/n))+1):
    if p % (i+1)**n == 0:
        m = (i+1)
print(m)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
a=[i for i in range(int(p**(1/n))+1)]
a[1]=0
b=int(p**0.5)
for j in a:
    if j>b:
        break
    elif j==0:
        continue
    for k in range(2*j,len(a),j):
        a[k]=0
c=[l for l in a if l!=0]
for m in range(len(c)):
    d=0
    while p%c[m]==0:
        p//=c[m]
        d+=1
    c[m]=[c[m],d]
e=1
for v in c:
    e*=v[0]**(v[1]//n)
print(e)

Submission status: Time Limit Exceeded

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

def heihou_hantei(n):
    m = int(n**0.5)
    return m if abs(m*m - n) < 1e-6 else 0

def kouyaku(n,p):
    if n==2:
        for i in range(round(((p**(1/n))/(2**n)+1))): 
            a=heihou_hantei(n)
            if a!=0:
                return a
    
            
    for i in range(round((p**(1/n)+1)),0,-1):        
        if p%i==0:
            if p%(i**n)==0:
                return i
            
print(kouyaku(n,p))

Submission status: Time Limit Exceeded

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

now = 1

x = 2
while P >= x ** N:
    if P % x == 0:
        while P % (x ** N) == 0:
            now *= x
            P = P / (x ** N)
        while P % x == 0:
            P = P / x

    x += 1


print(now)

Submission status: Time Limit Exceeded

Solution code:
#encoding:utf-8



import math
import random


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

N,P = map(int,input().split())
prime = Prime()
facters = prime.find_factors(P)

ans = 1
for key in facters.keys():
    if facters[key]/N >= 1:
        ans *= key**(facters[key]//N)
print(ans)


#
# if __name__ == '__main__':
#     prime = Prime()

Submission status: Time Limit Exceeded

Solution code:
# encoding: utf-8
import math, sys
N, P = map(int, input().split())

ans = 1
P_tmp = P
if N == 1:
    ans = P
else:
    for idx in range(1, P):
        # kurushimagire
        if idx == 1: p = 2
        else: p = idx * 2 - 1
        # escape
        if p ** N > P_tmp: break
        # process
        if P_tmp % (p ** N) == 0:
            # print("#", p, P_tmp)
            for i_p in range(1, P):
                if P_tmp % (p ** (N * (i_p + 1))) > 0: break
            P_tmp = P_tmp // (p ** (N * i_p))
            ans = ans * (p ** i_p)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
ans=1
yakusu = []
for i in range(1,int(math.sqrt(P))+1):
    if P%i == 0:
        yakusu.append(i)
        yakusu.append(P/i)
yakusu.sort()
f=P**(1/N)
bobo = []
for k in yakusu:
    if k <= (f+1):
        bobo.append(k)
bobo.reverse()
for j in bobo:
    if P/(j**N) in yakusu:
        ans=int(j)
        print(ans)
        break

Submission status: Time Limit Exceeded

Solution code:
import math

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

def C(N,P):
    if N == 1: return P
    a=P
    N1=2
    while N >= N1:
        N1*=2
        a=math.sqrt(a)

    res=1
    for i in range(1,int(a)+2):
        if P % i**N: continue
        res = i
    return res

print(C(n,p))

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
n = 1
a = []

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
    
p = math.ceil(P ** (1/N))

for i in range(p + 1):
  if is_prime(i) == True:
    a.append(i)
    
for i in a:
  while True:
    if P % (i ** N) == 0:
      n *= i
      P = P / (i ** N)
    else:
      break
  if P <= i ** N:
    break 
    
print(n)

Submission status: Time Limit Exceeded

Solution code:
import math

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

n = int(math.sqrt(P))
if N >= 4:
    n = int(math.sqrt(n))

for i in range(n+1)[::-1]:
    if i == 0:
        break
    _num = P
    cnt = 0
    if _num % pow(i, N) == 0:
        print(i)
        exit()
    '''
    while True:
        if _num % i == 0:
            _num = _num / i
            cnt += 1
        else:
            break
        if cnt == N:
            print(i)
            exit()
    '''
print(1)

Submission status: Time Limit Exceeded

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


ans = 1
tmp = P
start = P // (2**N) + 1
for i in range(start, 1, -1):
    newtmp, rest = divmod(tmp, (i**N))
    if rest == 0:
        ans = ans * i
        tmp = newtmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import time
start = time.time()

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

if n==1:
  print(p)
else:
  ans=1
  for i in range(1,100000000):
    tmp=i**n
    if (p>=tmp) and (p%tmp == 0):
     ans=i
    if(p<tmp):
      break
    now = time.time()
    if(now-start>1.5):
      break
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,P = map(int,input().split())
Z = 2
k = 1
if N==1:
    print(P)
    exit()
while(1):
    if P < (Z**N):
        break
    if P%(Z**N)==0:
        k*=Z
        P/=(Z**N)
        Z=1
    Z+=1
print(k)

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
ans=1
yakusu = []
for i in range(1,int(math.sqrt(P))+1):
    if P%i == 0:
        yakusu.append(i)
        yakusu.append(P/i)
yakusu.sort()
f=P**(1/N)
bobo = []
for k in yakusu:
    if k <= (f+1):
        bobo.append(k)
for j in bobo:
    if P/(j**N) in yakusu:
        ans=int(j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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


m=int(math.pow(p,1/n))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
import math
g = 1
if N ==1:
    print(P)
else:
    for i in range(1,math.ceil(P**(1/N))+1):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                g = i
    print(g)

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
ans=1
yakusu = []
for i in range(1,int(math.sqrt(P))+1):
    if P%i == 0:
        yakusu.append(i)
        yakusu.append(P/i)
yakusu.sort()
f=P**(1/N)
bobo = []
for k in yakusu:
    if k <= (f+3):
        bobo.append(k)
for j in bobo:
    if P/(j**N) in yakusu:
        ans=int(j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import time
start = time.time()

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

if n==1:
  print(p)
else:
  ans=1
  for i in range(1,100000000):
    tmp=i**n
    if (p>=tmp) and (p%tmp == 0):
     ans=i
    if(p<tmp):
      break
    now = time.time()
    if(now-start>1.9):
      break
  print(ans)

Submission status: Time Limit Exceeded

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

count = 1
ans = 0

if N > 1000001:
    print(1)
    exit()

while True:

    if count**N > P:
        break

    if P % count**N == 0:
        ans = count

    count += 1
 
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

def C(N,P):
    if N == 1: return P
    a=P
    N1=2
    while N >= N1:
        N1*=2
        a=math.sqrt(a)

    res=1
    for i in range(1,int(a)+2):
        if P % i**N: continue
        res = i
    return res

print(C(n,p))

Submission status: Time Limit Exceeded

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

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

primelist=[]
powerlist=[]

p=2
while P >= p**N:        
    f = 0
    for q in primelist:
        if p % q == 0:
            f = 1
            break
    if f == 1:
        p += 1
        continue
    else:
        k = 0
        while P % p == 0:
            P //= p
            k += 1
        primelist.append(p)
        powerlist.append(k//N)
        p += 1

ans = 1
for i in range(len(primelist)):
    ans *= (primelist[i]**powerlist[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
a=[i for i in range(p+1)]
a[1]=0
b=int(p**0.5)
for j in a:
    if j>b:
        break
    elif j==0:
        continue
    for k in range(2*j,p+1,j):
        a[k]=0
c=[l for l in a if l!=0]
for m in range(len(c)):
    d=0
    while p%c[m]==0:
        p//=c[m]
        d+=1
    c[m]=[c[m],d]
e=1
for v in c:
    e*=v[0]**(v[1]//n)
print(e)

Submission status: Time Limit Exceeded

Solution code:
import math

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

n = int(math.sqrt(P))
if N >= 4:
    n = int(math.sqrt(n))

for i in range(n+1)[::-1]:
    if i == 0:
        break
    _num = P
    cnt = 0
    while True:
        if _num % i == 0:
            _num = _num / i
            cnt += 1
        else:
            break
        if cnt == N:
            print(i)
            exit()
print(1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 1
ans = 0

if N > 1000001:
    print(1)
    exit

while True:
    
    if count**N > P:
        break

    if P % count**N == 0:
        ans = count

    count += 1
 
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N)))+2)):
    tmp=i**N
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

Submission status: Time Limit Exceeded

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


def fun(n, p):
    if n == 1:
        return p

    base = 1
    i = 2
    while True:
        if pow(base * i, n) > p:
            return base
        if p % pow(base * i, n) == 0:
            base = base * i
            i = 2
        else:
            if i == 2:
                i += 1
            else:
                i += 2


if __name__ == "__main__":
    N, P = map(int, input().split())

    output = fun(N, P)

    print(output)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
a = 2
c = 1
m = p**(1/n)
while a<=m:
    b = a**n
    if p%b == 0:
        c *= a
        p //= b
        if b>p:
            break
        while p%b == 0:
            c *= a
            p //= b
        a += 1
        if b>p:
            break
    else:
        a += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import sys


input = sys.stdin.readline
n, p = map(int, input().split())
if n == 1:
    ans = p
else:
    ans = 1
    for i in range(2, 10**6+1):
        check = i**n
        if check > p:
            break
        elif p % check == 0:
            ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N, P = map(int, input().split())
n = 1
p = math.ceil(P ** (1/N))
for i in range(2,p+1):
  while True:
    if P % (i ** N) == 0:
      n *= i
      P = P / (i ** N)
    else:
      break
  if P <= i ** N:
    break 
    
print(n)

Submission status: Time Limit Exceeded

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

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

primelist=[]
powerlist=[]

p=2
while P >= p**N:        
    f = 0
    for q in primelist:
        if p % q == 0:
            f = 1
            break
    if f == 1:
        p += 1
        continue
    else:
        k = 0
        while P % p == 0:
            P // p
            k += 1
        primelist.append(p)
        powerlist.append(k//N)
        p += 1

ans = 1
for i in range(len(primelist)):
    ans *= (primelist[i]**powerlist[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

def C(N,P):
    if N == 1: return P
    a=P
    if N >= 2 : a=math.sqrt(a)
    if N >= 4 : a=math.sqrt(a)
    if N >= 8 : a=math.sqrt(a)
    if N >= 16 : a=math.sqrt(a)
    if N >= 32 : a=math.sqrt(a)
    if N >= 64 : a=math.sqrt(a)
    if N >= 128 : a=math.sqrt(a)
    if N >= 256 : a=math.sqrt(a)
    if N >= 512 : a=math.sqrt(a)
    if N >= 1024 : a=math.sqrt(a)
    if N >= 2048 : a=math.sqrt(a)  
    res=1
    for i in range(1,int(a)+2):
        if P % i**N: continue
        res = i
    return res

print(C(n,p))

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
li = [1]
if N ==1:
    li.append(P)
    print(max(li))
else:
    for i in range(1,int(P**(1/N))+2):
        X = i**N
        if X > P:
            break
        else:
            if P % X == 0:
                li.append(i)
    print(max(li))

Submission status: Time Limit Exceeded

Solution code:
import math

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

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

L=primes(10**6+1)

N,P=map(int,input().split())
if N==1:
    print(P)
else:
    ans=1
    for i in L:
        while P%i==0:
            if P%(i**N)==0:
                ans*=i
                P=P//(i**N)
            else:
                P=P//i
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, p = (int(i) for i in input().split())
p_len = len(str(p))
ans = 1
for i in range(1, (10**(p_len // n + 1))):
    if p % i == 0:
        if p % (i**n) == 0:
            ans = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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


m=int(math.pow(p,1/n))

for i in range(m+1,0,-1):
    if p%(i**n) == 0:
        s = i
        break

print(s)

Submission status: Time Limit Exceeded

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


def fun(n, p):
    if n == 1:
        return p

    base = 1
    i = 2
    while True:
        if pow(base * i, n) > p:
            return base
        if p % pow(base * i, n) == 0:
            base = base * i
            i = 2
        else:
            i += 1


if __name__ == "__main__":
    N, P = map(int, input().split())

    output = fun(N, P)

    print(output)

Submission status: Time Limit Exceeded

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

now = 1

x = 2
while P > 1:
    if P % x == 0:
        while P % (x ** N) == 0:
            now *= x
            P = P / (x ** N)
        while P % x == 0:
            P = P / x

    x += 1


print(now)

Submission status: Time Limit Exceeded

Solution code:
n,p=[int(i) for i in input().split()]
i=2
ans=1
while p!=1 and i<=p:
    count=0
    while 1:
        if p%i==0:
            count+=1
            if count==n:
                count=0
                ans=ans*i
            p=p/i
        else:
            break
    i+=1
print(ans)

Submission status: Time Limit Exceeded

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


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

for i in reversed(range(1000000)):
    if p%(i+1)**n==0:
        print(i+1)
        sys.exit()

Submission status: Time Limit Exceeded

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

i = 1
ans = 1
R = int(P**(1/N)) + 1
if N > 1:
	for l in range(R):
		if P % (R-l)**N == 0:
			ans = R-l
			break
		i += 1
else:
	ans = P
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
def power(n, r):
    if r == 0:
        return 1
    if (r % 2):
        return n*power(n,r-1)
    else:
        d = power(n, r/2)
        return d*d
if n == 1:
    print(p)
    exit(0)
r = 1
ret = 1
while True:
    if power(r,n) > p:
        break;
    if ((p % power(r,n)) == 0):
        ret = max(ret, r);
    r += 1
print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,p = input().split()
n = int(n)
p = int(p)
i = 2
a = o = 1
while a<p:
    a = i**n
    if p%a==0:
        o = i
    i += 1
print(o)

Submission status: Time Limit Exceeded

Solution code:
import sys


def new_pow(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return new_pow(x ** 2, n // 2)
    else:
        return x * new_pow(x ** 2, (n - 1) // 2)

input = sys.stdin.readline
n, p = map(int, input().split())
if n == 1:
    ans = p
else:
    ans = 1
    for i in range(2, new_pow(10, 6)+1):
        check = new_pow(i, n)
        if check > p:
            break
        elif p % check == 0:
            ans = i
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit(0)
r = 1
ret = 1
while True:
    if r**n > p:
        break;
    if ((p % r**n) == 0):
        ret = max(ret, r);
    r += 1
print(ret)

Submission status: Time Limit Exceeded

Solution code:
import math
n,p=map(int,input().split())
s=0
I=p
R=int(I)
l=[]
if p==1:
  print(1)
  exit()
while s==0:
  for i in range(2,R//2+1):
    if I%i==0:
      I=I/i
      if I==1:
          s=1
      l.append(i)
      break
l2=list(set(l))
x=1
for i in l2:
  y=l.count(i)
  if y>=n:
    x*=pow(i,y//n)
print(x)