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 = (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**n) == 0:
        ans = i
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

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

Submission status: Time Limit Exceeded

Solution code:
import math

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


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

s = 1

if n == 1:
    s = p
else:
    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:
N, P = map(int, input().split())

from math import sqrt
from collections import Counter

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    #if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

p = prime_factorization(P)
c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1
for i,v in zip(l,j):
    ans *= i**v

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,p = input().split()
n = int(n)
p = int(p)
i = 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:
(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**N) == 0:
            P //= (p**N)
            k += 1
        primelist.append(p)
        powerlist.append(k)
        p += 1

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int ,input().split())
x=int(pow(b,1/a))
x+=1
while x>=1:
    if b%(x**a)==0:
        print(x)
        exit()
    x-=1

Submission status: Time Limit Exceeded

Solution code:
from math import floor
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, floor(p**(1/n))+2):
        if p % i**n ==0:
            res = i
    print(res)

Submission status: Time Limit Exceeded

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

from math import sqrt
from collections import Counter

def prime_factorization(n):
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

p = prime_factorization(P)
c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1
for i,v in zip(l,j):
    ans *= i**v

print(ans)

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 > 2:
	for l in range(R): 
		if P % i**N == 0:
			ans = i
		i += 1
elif N == 2:
	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())
out=1
tm = int(pow(p, 1/n))
for i in range(2,tm+1):
    if i==2:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
    elif i==3:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
    elif i%2!=0 and i%3!=0:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
        if p < i**n:
            break
print(out)

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
d=1
i=0
while (d<=p):
    i=i+1
    if (p%i==0):
        d=pow(i,n)
        if (p%d==0):
            ans=i

print (ans)

Submission status: Time Limit Exceeded

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

gcd = 1
tmp_P = P

for i in range(1, P+1):
    t = pow(i, N)
    if t > P:
        break
    if P % t == 0:
        gcd = i

print(gcd)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum



N, P = map(int, input().split(' '))
if N == 1:
    print(P)
    exit()
elif P < 2**N:
    print(1)
    exit()

ans = 1
t = 2
while t**N < P:
    t += 1
prime_nums = seachPrimeNum(t)

for a in prime_nums:
    if P % (a**N) == 0:
        temp = P // (a**N)
        count = 1
        while temp % (a**N) == 0:
            count += 1
            temp = temp // (a**N)
        ans *= a**count

    elif a**N > P:
        break
print(ans)

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:
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
  print(ans)

Submission status: Time Limit Exceeded

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

def kouyaku(n,p):
    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 = map(int, input().split())

p2 = int(p ** (1 / n)) + 1

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

Submission status: Time Limit Exceeded

Solution code:
import math

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


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

s = 1

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

print(s)

Submission status: Time Limit Exceeded

Solution code:
n, p = map(int, input().split())
out=1
tm = int(pow(p, 1/n))
for i in range(2,tm+1):
    if i==2:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
            
    elif i%2==1:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
            
        if p < i**n:
            break
print(out)

Submission status: Time Limit Exceeded

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

from math import sqrt
from collections import Counter

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

p = prime_factorization(P)
c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1
for i,v in zip(l,j):
    ans *= i**v

print(ans)

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 p == 1 or b>p:
            break
        while p%b == 0:
            c *= a
            p //= b
        a += 1
        if p == 1 or b>p:
            break
    else:
        a += 1
print(c)

Submission status: Time Limit Exceeded

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

count = 1
ans = 0

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

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

tmp = math.sqrt(p)

if n == 1:
    print(p)
else:
    for i in range(1,int(tmp)+1):
        if p % (i ** n) == 0:
            ans = i
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, p = map(int, input().split())
out=1
tm = int(pow(p, 1/n))
for i in range(2,tm+1):
    while p%(i**n)==0:
        p = p//(i**n)
        out *= i
        
    if p < i**n:
        break
print(out)

Submission status: Time Limit Exceeded

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

ans = 1
tmp = P
for i in range(2, P):
    while True:
        rest = tmp % (i ** N)
        newtmp = tmp // (i ** N)
        # print(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:
import sys


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

Submission status: Time Limit Exceeded

Solution code:
n,p=map(int,input().split())
d=1
i=0
while (d<=p):
    i=i+1
    d=pow(i,n)
    if (p%d==0):
        ans=i

print (ans)

Submission status: Time Limit Exceeded

Solution code:
import math

N, P = (int(i) for i in input().split())
x = 1
ans = 0
for i in range(int(math.pow(P, 1.0/N))+1):
    if P%(x**N)==0:
        if ans < x:
            ans = x
    x += 1
print(ans)

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):
    if p % i**n == 0:
        ans = i
    if i**n >= p:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#encoding:utf-8

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

def factorint(N):
    table = {}
    reset = False
    while(N > 1):
        for i in range(2,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    if i in table.keys():
                        table[i] += 1
                    else:
                        table[i] = 1
                reset = True
                # print(N)
                break
    return table

facters = factorint(P)
# print(facters)

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

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:
N,P = map(int,input().split())
k = 1
c = int(P**(1/N))+2
for i in range(c,1,-1):
    if P%(i**N)==0:
        k=i
        break
print(k)

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 % i**N == 0:
			ans = i
		i += 1
else:
	ans = P
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, floor(p**(1/n))+10):
        if p % i**n ==0:
            res = i
    print(res)

Submission status: Time Limit Exceeded

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

#%%
# n, p = 3, 24

#%%

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

Submission status: Time Limit Exceeded

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


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

    x_val = int((p ** (1/n)) // 1) + 1
    for _ in range(x_val-1):
        if p % x_val == 0:
            if p % (x_val ** n) == 0:
                break
            else:
                x_val -= 1
        else:
            x_val -= 1

    print(x_val)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

    elif i%2!=0:
        while p%(i**n)==0:
            p = p//(i**n)
            out *= i
            
        if p < i**n:
            break
print(out)

Submission status: Time Limit Exceeded

Solution code:
import math
q = input().split()
n = int(q[0])
p = int(q[1])
def isprime(n):
    for i in range(int(math.sqrt(n))+1):
        if i == 0 or i == 1:
            continue
        if n % i == 0:
            return False
    return True
if p == 1:
    print(1)
else:
    a = 1
    i = 2
    while True:
        if isprime(i):
            c = 0
            l = p
            while l % i == 0:
                l /= i
                c += 1
            if c//n != 0:
                a *= i**(c//n)
        if i**n > p:
            break
        i += 1
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import math
import random

N, P = map(int, input().split())
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()

if __name__ == '__main__':
    prime = Prime()
    #assert prime.find_factors(36610051291281) == {653: 1, 593783: 1, 3: 3, 13: 1, 269: 1}
    table = prime.find_factors(P)

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

print(c)

Submission status: Time Limit Exceeded

Solution code:
N, P = map(int, input().split())
m = int(P**(1/N)+1)
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0:
      break
  m -= 1
print(m)

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):
        while M%i==0:
            if M%(i**N)==0:
                ANS*=i
                M=M//(i**N)
            else:
                M=M//i
    print(ANS)

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
        while p%b == 0:
            c *= a
            p //= b
        a += 1
        if p == 1 or b>p:
            break
    else:
        a += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n,p = map(int,input().split())
if n == 1:
    print(p)
    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: Time Limit Exceeded

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


def main():
    from math import sqrt

    n, p = map(int, input().split())
    ans = 1
    numbers = set()

    for i in range(1, int(sqrt(p)) + 1):
        a, b = divmod(p, i)

        if b == 0:
            numbers.add(i)
            numbers.add(a)

    for number in numbers:
        c, d = divmod(p, number ** n)

        if d == 0 and number ** n <= p:
            ans = max(ans, number)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i] and  i >= int(math.sqrt(P)+1)]

primax = int(1e8) - 10000000#int(1e7) + 9 * int(1e6) + 9 * int(1e5) + 9 * int(1e4)
primes = get_prime(primax)
# print(primes)


def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])

ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

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(int(p**(1/n))+1)):
    if p%(i+1)**n==0:
        print(i+1)
        sys.exit()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

i = 2
l = 1
while True:
  if P == 1:
    break
  if P % i == 0:
    ni = 0
    while P%i == 0:
      ni += 1
      P //= i
    l *= i ** (ni // N)
  else:
    i += 1

print(l)

Submission status: Time Limit Exceeded

Solution code:
import math
if __name__ == "__main__":
    n, p = map(int, input().split())
    res = 1
    sup = math.ceil(p ** (1 / n))
    i = 2
    while(i <= sup and i <= p):
        if p % i == 0:
            k = 1
            p /= i
            while(p % i == 0):
                p /= i
                k += 1
            if k >= n:
                for s in range(k // n):
                    res *= i
        i += 1
    print(res)

Submission status: Time Limit Exceeded

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


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

    x_val = int((p ** (1/n)) // 1)
    x_val += 1
    for _ in range(x_val-1):
        if p % (x_val ** n) == 0:
            break
        else:
            x_val -= 1

    print(x_val)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

insuList=[]
warukazu = 2
while (P > 1):
  if P % warukazu == 0:
    P = P / warukazu
    insuList.append(warukazu)
  else:
    warukazu+=1

ans=1
c=collections.Counter(insuList)
for key in c.keys():
  while c[key] >= N:
    ans=ans*key
    c[key] -= N

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, P = (int(i) for i in input().split())
x = 1
ans = 0
while x**N <= P:
    if P%(x**N)==0:
        if ans < x:
            ans = x
    x += 1
print(ans)

Submission status: Time Limit Exceeded

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