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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
import math


def factorization(n):
    f = []
    if n > 1 and n % 1 == 0:
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                f.append(i)
                m = n // i
                j = 2
                while j <= m:
                    if m % j == 0:
                        f.append((j))
                        m = m // j
                        j = 2
                    else:
                        j += 1
                break
        else:
            return 0
    return f


def main():
    a = list(map(int, input().split()))
    c = collections.Counter(factorization(a[1]))
    ans = 1
    for s in c:
        if math.floor(c[s] / a[0]) >= 1:
            ans *= s * math.floor(c[s] / a[0])
        else:
            break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

kisu = False if p % 2 == 0 else True

num2 = int(p ** (1/n))
if kisu:
    num2 = num2 - 1 if num2 % 2 == 0 else num2
else:
    num2 = num2 - 1 if num2 % 2 != 0 else num2

for i in range(num2, 0, -2):

    if p % (i ** n) == 0:
        print(i)
        break

else:
    print(1)

Submission status: Wrong Answer

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

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

primelist=[]
powerlist=[]

p=2
while 1:
    Q = p**N
    if P < Q:
        break
    elif P == Q:
        primelist.append(p)
        powerlist.append(1)
        break
    elif p**(N+1) > P:
        p = P**(1/N)
        if p == int(p):
            primelist.append(int(p))
            powerlist.append(1)
        break

    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: Wrong Answer

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

table = []

while i * i <= P:

  while P % i == 0:

    P /= i

    table.append(i)

  i += 1

if P > 1:

  table.append(P)

            

c = Counter(table)

temp = [i[0] for i in c.items() if i[1] >= N]

temp.append(1)

print(int(reduce(lambda x,y:x*y,temp)))

Submission status: Wrong Answer

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

kisu = False if p % 2 == 0 else True

num2 = int(p ** (1/n))
if kisu:
    num2 = num2 - 1 if num2 % 2 == 0 else num2
else:
    num2 = num2 - 1 if num2 % 2 != 0 else num2

for i in range(num2, 0, -2):
    print(p, i, n)

    if p % (i ** n) == 0:
        print(i)
        break

else:
    print(1)

Submission status: Wrong Answer

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


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

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

y=prime_factors(p)
if not y:
    print(1)
    exit()
ans=1
cnt=1
before=0
f=False
for i in y:
    if i==before:
        cnt+=1
    else:
        cnt=1
    if cnt>=n:
        ans*=i
        cnt=1
        f=True
    before=i
if f:
    print(ans)
else:
    print(p)

Submission status: Wrong Answer

Solution code:
a=[]
a=input().split(" ")
N=int(a[0])
P=int(a[1])
a=P**(1/N)
#aは約数の最大値

b=int(a)#aを整数化(bとする)
c=0
i=0
for i in range(1,b+1):#Pを1からbまで割って割り切れたものをリストcに格納

    if P%(i**N)==0 :
        c=i
    else:
        continue
print(c)

Submission status: Wrong Answer

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

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

b = [False] * 1000001
prime = []
b[1] = True

for i in range(2, 1000001):
    if b[i]:
        continue
    k = i + i
    while k < 1000001:
        b[k] = True
        k += i

    prime.append(i)

prime_num = [0] * len(prime)

for i in range(len(prime)):
    while p % prime[i] == 0:
        prime_num[i] += 1
        p //= prime[i]

if sum(prime_num) == 0:
    print(1)
    exit()

idx = []
for i in range(len(prime) - 1, -1, -1):
    if prime_num[i] >= n:
        idx.append(i)
        break

if len(idx) == 0:
    print(1)
    exit()

for i in range(idx[0] - 1, -1, -1):
    if prime_num[i] >= prime_num[idx[0]]:
        idx.append(i)

mn = 10 ** 13
for x in idx:
    mn = min(mn, prime_num[x])

a = mn // n

ans = 1
for x in idx:
    ans *= prime[x] ** a

print(ans)

Submission status: Wrong Answer

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

import math
#を素因数分解
# print(p)

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if n==1:
    print(p)

if p==1:
    print(1)

if ((n!=1) and (p!=1)):
    #もし素数ならwhileの計算とばす
    
    sosubool = is_prime(p)
    yakusu=[1]

    p1 = p


    while(1):
        if sosubool==True:
            break
        bool = False

        for i in range(2,(p1//2+1)):
            if p1%i==0:
                yakusu.append(i)
                p1=p1//i
                bool = True
                break
        if bool == False:
            yakusu.append(p1)
            break

    if yakusu.count(p)!=1:
        yakusu.append(p)
    # print(yakusu)
    maxyakusu=1
    t=0
    while(1):
        ya=yakusu[t]
        bool2=True
        for i in range(t+1,n+t):
            if yakusu[i]!=ya:
                bool2=False
                t+=1
                break
        if bool2==True:
            maxyakusu*=ya
            t+=n
        if n+t >=len(yakusu):
            break

    print(maxyakusu)

Submission status: Wrong Answer

Solution code:
import math

N, P = map(int, input().split())
result = 1
i = math.floor(math.pow(P, (1.0/N)))


while i > 1:
    if P % int(math.pow(i, N)) == 0:
        result = i
        break
    i -= 1

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
            break
    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: Wrong Answer

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

print(GCD)

Submission status: Wrong Answer

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


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

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

    if p % 2 == 0:
        if x_val % 2 != 0:
            x_val -= 1

        while x_val >= 2:
            if p % (x_val ** n) == 0:
                break
            else:
                x_val -= 2
    else:
        if x_val % 2 != 1:
            x_val -= 1

        while x_val >= 1:
            if p % (x_val ** n) == 0:
                break
            else:
                x_val -= 2

    print(x_val)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def fun(n, p):
    sosuu = [2, 3]
    if n == 1:
        return p

    base = 1
    i = 2
    while True:
        base_i = base * i
        pow_base_i_n = pow(base * i, n)
        if pow(base * i, n) > p:
            return base
        if p % pow(base * i, n) == 0:
            if i not in sosuu:
                sosuu.append(i)
            base = base * i
            # k = 0
            # i = sosuu[k]
            # i = 2
            i = sosuu[-1]
        else:
            # k += 1
            # if len(sosuu) > k + 1:
            #     i = sosuu[k+1]
            # else:
            #     i += 2
            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: Wrong Answer

Solution code:
import sys
from collections import Counter
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
ls = Counter(prime_decomposition(p)).most_common()
c = 1
for i in range(len(ls)):
    if ls[i][1] < n:break
    c *= ls[i][1]//n * ls[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
import sys
import traceback

N, P = [int(i) for i in input().split()]
p = []
ans = 1

class PrimeFractorization:
    def __init__(self):
        self.a = 2

    def decomposit_prime(self, n):
        try:
            while n >= self.a * self.a:
                if n % self.a == 0:
                    p.append(self.a)
                    n //= self.a
                else:
                    self.a += 1
            p.append(n)
        except Exception as e:
            raise

obj = PrimeFractorization()
obj.decomposit_prime(P)

p2 = set(p)

for a in p2:
    if p.count(a) >= N:
        ans *= int(a)

if N == 1:
    print(P)
else:
    print(ans)

Submission status: Wrong Answer

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

table = []

while i * i <= P:

  while P % i == 0:

    P /= i

    table.append(i)

  i += 1

if P > 1:

  table.append(P)

            

c = Counter(table)

temp = [i[0] for i in c.items() if i[1] >= N]

if temp == []:

  temp.append(1)

print(int(reduce(lambda x,y:x*y,temp)))

Submission status: Wrong Answer

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
    a = a*n
print(o)

Submission status: Wrong Answer

Solution code:
import numpy as np

args = [int(i) for i in input().split()]
N = args[0]
P = args[1]

num = 1
i = 2

count = 0
while True:
    if P % i == 0:
        P /= i
        count += 1
    else:
        if count >= N:
            num *= i
        break

i = 3
while i <= P:
    count = 0
    while True:
        if P % i == 0:
            P /= i
            count += 1
        else:
            if count >= N:
                num *= i
            i += 2
            break

print(num)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n,p = map(int,input().split())
if n >= 40:
    print(1)
    sys.exit()
if n == 1:
    print(p)
    sys.exit()
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
ls = Counter(prime_decomposition(p)).most_common()
c = 1
for i in range(len(ls)):
    if ls[i][1] < n:break
    c *= ls[i][1]//n * ls[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
import math

if __name__ == '__main__':
    n, p = list(map(int, input().split()))
    plist = []

    for i in range(2, int(math.sqrt(p))):
        if i**2 > p:
            break
        while p % i == 0:
            p //= i
            plist.append(i)
    if p > 1:
        plist.append(p)

    a = []
    if not plist:
        print(1)
        exit()
    elif len(plist) == 1:
        print(plist.pop())
        exit()
    else:
        for i in list(set(plist)):
            if plist.count(i) >= n:
                a.append(i)
    ans = 1
    while a:
        ans *= a.pop()

    print(ans)

Submission status: Wrong Answer

Solution code:
a=[]
a=input().split(" ")
N=int(a[0])
P=int(a[1])
a=P**(1/N)
#aは約数の最大値

b=int(a)#aを整数化(bとする)
c=[]
i=0
for i in range(1,b+1):#Pを1からbまで割って割り切れたものをリストcに格納

    if P%(i**N)==0 :
        c.append(int(i))
    else:
        continue
print(max(c))

Submission status: Wrong Answer

Solution code:
import math

N, P = map(int, input().split())
result = 1
i = math.floor(math.pow(P, (1.0/N)))


if N != P:
    while i > 1:
        if P % math.pow(i, N) == 0:
            result = i
            break
        i -= 1

print(result)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
m=int(pow(p,1/n))

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

Submission status: Wrong Answer

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

max_canditate = int(p**(1. / n))
for cand in range(max_canditate, 0, -1):
    if p % (cand ** n) == 0:
        # max_cand^3 * ? = p was found -> GCD is max_cand
        print(cand)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
c = 1
O = P
if P % N == 0:
    O = int(P/N)

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(O)

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

Submission status: Wrong Answer

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

ans = 1
t = 2
temp = t**N
a = []
b = []
while temp < P:
    b.append(t)
    a.append(temp)
    t += 1
    temp = t**N
    
for i in range(len(a))[::-1]:
    if P % a[i] == 0:
        print(b[i])
        exit()
print(1)

Submission status: Wrong Answer

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

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


prime = Prime()

factors = prime.find_factors(P)

GCD = 1

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

print(GCD)

Submission status: Wrong Answer

Solution code:
def isPrime(n) : 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True
n,p=map(int,input().split())
if isPrime(p)==True:
    print(1)
else:
    d={}
    xx=p
    while xx%2==0:
        if 2 in d:
            d[2]+=1
        else:
            d[2]=1
        xx=xx//2
    for i in range(3,int(xx*(0.5))+1,2):
        while xx%i==0:
            if i in d:
                d[i]+=1
            else:
                d[i]=1
            xx=xx//i
    if xx>2:
        if xx in d:
            d[xx]+=1
        else:
            d[xx]=1
    ans=1
    for key,value in d.items():
        if value>=n:
            ans*=(key*(value//n))
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
maxfac = int(P**(1/N))
# print(range(1,maxfac+1))
for i in range(1,maxfac+1)[::-1]:
    p = i**N
    # print(P%p)
    if P%p == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import numpy as np

args = [int(i) for i in input().split()]
N = args[0]
P = args[1]

num = 1
i = 2
while i <= P:
    count = 0
    while True:
        if P % i == 0:
            P /= i
            count += 1
        else:
            if count >= N:
                num *= i
            i += 1
            break
print(num)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


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

    maxi = -1e9

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

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

    S = set()
    x = int(p ** (1 / n))
    for i in range(x, 1, -1):
        if p % i != 0:
            continue
        else:
            y = p // i
            if y % (n - 1) == 0:
                z = gcd(i, y // (n - 1))
                if z != 1:
                    v = p % (z ** n)
                    #print(z, p)
                    if v == 0:
                        maxi = max(maxi, z)

    if maxi == -1e9:
        print(1)
    else:
        print(maxi)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,p=map(int, input().split())
c=1
m=int(pow(p,1/n))+1

def facto(p1,n1):
    m1=int(pow(p1,1/n1))+2
    for i in range(m1):
        if p1 % (i+2)**n1 == 0:
            print(i+2)
            return(i+2)
    return 1

re=0
while(re!=1):
    re=facto(p,n)
    c=c*re
    p=p/(re**n)
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lists = [int(x) for x in input().split()]
N = lists[0]
P = lists[1]
if N==1:
    print(P)
elif P==1:
    print(P)
else:
    primes=[2];
    if N>2: 
        for L in range(3,int(P**(1.0/N))):
            chk=True
            for L2 in primes:
                if L%L2 == 0:
                    chk=False
                if chk==True:
                    primes.append(L)
    gcd = []
    i = 0;
    while i<len(primes):
        if P%(primes[i]**N)==0:
            gcd.append(primes[i])
        i+=1
    ans = 1
    for i in range(len(gcd)):
        ans *= gcd[i]
    print(ans)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
s = 0 
a = int(p)
b = {}

def calc(x):
    c = []
    b, e = 2, 0
    while b * b <= x:
        while x % b == 0:
            x = x // b
            e = e + 1
        if e > 0:
            c.append((b, e))
        b, e = b + 1, 0
    if x > 1:
        c.append((x, 1))
    return c
    
    
if p == 1:
    print(1)
else:
    d = calc(p)
    ans = 1
    for i in range(len(d)):
        if d[i][1] >= n:
            ans *= d[i][0]
    print(ans)

Submission status: Wrong Answer

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