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: Runtime Error

Solution code:
n,p = map(int,input().split())
if n==1:
 return p
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%int(a[j]**n) == 0:
  c = 0
  while q%int(a[j]**n) == 0:
   q /= (a[j]**n)
   c += 1
  res *= int(a[j]**c)
print(res)

Submission status: Runtime Error

Solution code:
def yakusu_maker(num):
    yakusuu_array=[1]
    for i in reversed(range(1,num)):
        if num % i == 0:
            yakusuu_array.append(i)
            return(yakusuu_array[-1])
            break
            

import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)



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

yakusuu_array=[]
yakusuu_array.append(yakusu_maker(P))
a_array=[]
result_array =[]
Pre_num = P
if P==1:
    print(1)
else:
    for i in range(N-1):
            a_array.append(yakusuu_array[-1])
            result_array.append(int(Pre_num/yakusuu_array[-1]))
            Pre_num = yakusuu_array[-1]
            yakusuu_array.append(yakusu_maker(Pre_num))
    result_array.append(a_array[-1])

    print(gcd_list(result_array))

Submission status: Runtime Error

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

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

for i in seachPrimeNum(P):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
        dic[i] = num
        
ans = 1
for i in dic:
    if M == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//M))
print(ans)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%int(a[j]**n) == 0:
  c = 0
  while q%int(a[j]**n) == 0:
   q /= (a[j]**n)
   c += 1
  res *= int(a[j]**c)
print(res)

Submission status: Runtime Error

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)))+2)):
    tmp=math.pow(i-1,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if (P/i)%tmp==0:
        ans=i
        break
print(ans)

Submission status: Runtime Error

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

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

for i in seachPrimeNum(P):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
        dic[i] = num
        
ans = 1
for i in dic:
    if N == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//N))
print(ans)

Submission status: Runtime Error

Solution code:
import math
a = list(map(int, input().split()))
N = a[0]
P = a[1]
insu = []
sisu = []
offset = []
temp = int(math.sqrt(P))
ans = 1
for i in range(2, temp):
    cnt = 0
    while P % i == 0:
        P //= i
        cnt += 1
    if cnt > 0:
        insu.append(i)
        sisu.append(cnt)
        offset.append([i, cnt])

if len(insu) == 0:
    if not P == 1:
        insu.append(P)
        sisu.append(1)
        offset.append([P, 1])

A = sum(sisu)
for i in range(N-A):
    

for i in sisu:
    if i > A - i:
        if 
            ans = insu[sisu.index(i)]
    
print(ans)

Submission status: Runtime Error

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)))+2)):
    tmp=math.pow(i,N-1)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if (P/i)%tmp==0:
        ans=i
        break
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
import math

n, p = map(int, input().split())
if n != 1:
    table = [0] * (math.sqrt(p) + 1)

    pl = []
    ans = 1

    for i in range(2, math.sqrt(p)+1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, math.sqrt(p)+1, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
import math

n, p = map(int, input().split())
if n != 1:
    table = [0] * (math.sqrt(p) + 1)

    pl = []
    ans = 1

    for i in range(2, math.sqrt(p)+1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, p + 3, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p
print(ans)

Submission status: Runtime Error

Solution code:
def yakusu_maker(num):
    yakusuu_array=[1]
    for i in range(1,num):
        if num % i == 0:
            yakusuu_array.append(i)
    return(yakusuu_array[-1])

import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)



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

yakusuu_array=[]
yakusuu_array.append(yakusu_maker(P))
a_array=[]
result_array =[]
Pre_num = P
if P==1:
    print(1)
else:
    for i in range(N-1):
            a_array.append(yakusuu_array[-1])
            result_array.append(int(Pre_num/yakusuu_array[-1]))
            Pre_num = yakusuu_array[-1]
            yakusuu_array.append(yakusu_maker(Pre_num))
    result_array.append(a_array[-1])

    print(gcd_list(result_array))

Submission status: Runtime Error

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

def yakusuSub(p,d,arr):
    if p==1:return arr
    if p/d==int(p/d):
        arr.append(d)
        return yakusuSub(p/d,d,arr)
    else:
        return yakusuSub(p,d+1,arr)
 
def yakusu(p):
    return yakusuSub(p,2,[])
 
if n==1:
    print(p)
    exit()
 
y=yakusu(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: Runtime Error

Solution code:
a,b=map(int,input().input())
if a==0:
    print(b)
elif b==1:
    print(b)
else:
    print(b)

Submission status: Runtime Error

Solution code:
np = input().split(" ")
n = int(np[0])
p = int(np[1])

elem_list = []

def search(n, p, elem_list, i):
  elem = i ** n
  while elem <= p:
    elem = i ** n
    if p % elem == 0:
      elem_list.append(elem)
      return search(n, int(p / elem), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
elif p == 1:
  print(1)
#elif n > p:
  #print(1)
else:
  import functools
  import operator
  elem_list = search(n, p, elem_list, 2)
  print(elem_list)
  deles = []
  num = len(elem_list)
  for i in range(num):
    for j in range(i):
        e = elem_list[i]
        f = elem_list[j]
        #print(str(i) + " " + str(j))
        if e != f:
            if e % f == 0:
                dele = f
                #print(dele)
                deles.append(dele)
                
  print(deles)
  if len(deles) != 0:
    dele = list(set(deles))
    for e in dele:
      elem_list.remove(e)
    #print(elem_list)
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Runtime Error

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
if (t-1)**N == P:
    print(t-1)
    exit()
else:
    a = seachPrimeNum(int((t-1)/2))
    
a_N = [a[i] ** N for i in range(len(a))]
check_P = P
for i in range(len(a_N)):
    if P % a_N[i] == 0:
        temp = P // a_N[i]
        count = 1
        while temp % a_N[i] == 0:
            count += 1
            temp = temp // a_N[i]
        ans *= a[i]**count
        check_P = temp
    elif a_N[i] > check_P:
        break
print(ans)

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int power(int f, int e){
        int ret = 1;
        while(e > 0){
                ret = ret * f;
                e--;
        }
        return ret;
}

long solve(long x, int p, int a, long n){
        if (n==1)
                return x;
        if (power(p,n) > x)
                return a;
        int c = 0;
        while(x % p == 0){
                x = x/p;
                c++;
        }
        if (c!=0)
                a = a * power(p, (c/n));
        if (p == 2)
                return solve(x,p+1,a,n);
        return solve(x,p+2,a,n);
}

int main(){
        long n,p;
        scanf("%ld %ld",&n,&p);
        printf("%ld\n",solve(p,2,1,n));
        return 0;
}

Submission status: Runtime Error

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:
    q=math.ceil((j**(N/2))**2)
    if P/q in yakusu:
        ans=int(j)
        print(ans)
        break

Submission status: Runtime Error

Solution code:
np = input().split(" ")
n = int(np[0])
p = int(np[1])

elem_list = []

def search(n, p, elem_list, i):
  elem = i ** n
  while elem <= p:
    elem = i ** n
    if p % elem == 0:
      elem_list.append(elem)
      return search(n, int(p / elem), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
elif p == 1:
  print(1)
#elif n > p:
  #print(1)
else:
  import functools
  import operator
  elem_list = search(n, p, elem_list, 2)
  #print(elem_list)
  deles = []
  num = len(elem_list)
  for i in range(num):
    for j in range(i):
        e = elem_list[i]
        f = elem_list[j]
        print(str(i) + " " + str(j))
        if e != f:
            if e % f == 0 or f % e == 0:
                dele = min(e,f)
                #print(dele)
                deles.append(dele)
                
  #print(deles)
  if len(deles) != 0:
    dele = list(set(deles))
    for e in dele:
      elem_list.remove(e)
    #print(elem_list)
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Runtime Error

Solution code:
import sys
def soin(n):
    I=n
    s=0
    R=int(I)
    L=[]
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    if len(L)==1:
        print(R)
    else:
        print(L)

n,p= map(int,input().split())
if n==1:
    print(p)
    sys.exit()
l=soin(p)
if len(l)<n:
    print(1)
    sys.exit()
print(min(l))

Submission status: Runtime Error

Solution code:
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(int(n))
  return table


cnt=1
gcd=1
b,p=map(int,input().split())
a=prime_decomposition(p)
print(a)
if b==1:

if b>1:
  l=len(a)
  for i in range(l-1):
    if a[i+1]==a[i]:
      cnt+=1
      if cnt==b:
        gcd*=a[i]
        cnt=1
    else:
      cnt=1
  print(gcd)

Submission status: Runtime Error

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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
    
p = math.ceil(P ** (1/N))

a = primes(p + 1)
    
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: Runtime Error

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/2))**2 in yakusu:
        ans=int(j)
        print(ans)
        break

Submission status: Runtime Error

Solution code:
import collections
from functools import reduce

n = int(input())

a = list([int(input()) for _ in range(n)])

kai = 0

if len(set(a)) == 1:
    if len(set(a)) % 2 == 1:
        print('first')
    else:
        print('second')

    exit(0)


def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


mi = int(reduce(gcd, a))
a = list(map(lambda x: x // mi, a))


def eat(l):
    li = reduce(gcd, l)
    if li != 0:
        l = list(map(lambda x: x//li, l))


    for i in range(len(l)):
        if l[i] % 2 == 1:
            l[i] -= 1

    print(l)
    return l



while True:
    kai += 1

    if a.count(0) == n-1:
        nokori = collections.Counter(a).most_common()[1][0]
        kai += (nokori - 1)

        if kai % 2 == 0:
            print('second')
        else:
            print('first')

        exit(0)


    a = eat(a)

Submission status: Runtime Error

Solution code:
from sympy.ntheory import factorint
from operator import itemgetter
from math import floor

def main():
    a = list(map(int, input().split()))
    # l = factorization(a[1])
    # c = collections.Counter(l)
    c = sorted(factorint(a[1]).items(), key=itemgetter(1), reverse=True)
    ans = 1
    for s in c:
        tmp = list(s)
        if floor(tmp[1] / a[0]) >= 1:
            ans *= tmp[0] * floor(tmp[1] / a[0])
        else:
            break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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



def yakusuSub(p,d,arr):
    if p==1:return arr
    if p/d==int(p/d):
        arr.append(d)
        return yakusuSub(p/d,d,arr)
    else:
        return yakusuSub(p,d+1,arr)

def yakusu(p):
    return yakusuSub(p,2,[])

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

y=yakusu(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: Runtime Error

Solution code:
import math
N, P = map(int, input().split())
if N == 1:
    print(P)
else:   
    ans = 1
    q = 1
    while q <= math.pow(P, 1.0/N):
        if P % (q**N) == 0:
            if q % ans != 0:
                ans = int(q * ans / math.gcd(q, ans))
            else:
                ans = q
            q = ans + 1
        else:
            q += 1
    print(ans)

Submission status: Runtime Error

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

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

if n==1:
    print(p)

if p==1:
    print(1)

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

    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)


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

Submission status: Runtime Error

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

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

if n==1:
    print(p)

if p==1:
    print(1)

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

    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)


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

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = [int(input()) for _ in range(n)]

a_list.sort(reverse=True)

if n == 1:
    print("first" if a_list[0] % 2 == 1 else "second")
    exit()

elif n == 2:
    max_num = a_list[0]
    second_num = a_list[1]
    num = max_num - second_num
    print("first" if num % 2 == 1 else "second")
else:
    max_num = a_list[0] - a_list[2]
    second_num = a_list[1] - a_list[2]
    num = max_num - second_num
    if num == 0:
        print("second")
    print("first" if num % 2 == 1 else "second")

Submission status: Runtime Error

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)))+2)):
    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)

Submission status: Runtime Error

Solution code:
n, p = list(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

fact = prime_factors(p)
if len(fact) <= 1:
    print(1)
    exit(1)
i = 0
while 1:
    if len(fact) == n:
        break
    if i >= len(fact):
        i = 0
    if len(fact) <= 1:
        print(1)
        exit(1)
    fact[i] = fact[i]*fact[-1]
    fact.pop()
    i += 1
print(min(fact))

Submission status: Runtime Error

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



def yakusuSub(p,d,arr):
    if p==1:return arr
    if p/d==int(p/d):
        arr.append(d)
        return yakusuSub(p/d,d,arr)
    else:
        return yakusuSub(p,d+1,arr)

def yakusu(p):
    return yakusuSub(p,2,[])

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

y=yakusu(p)
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: Runtime Error

Solution code:
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: Runtime Error

Solution code:
import numpy as np
from random import shuffle
from itertools import combinations, permutations

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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 np.array(factors)

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

ni = prime_factors(p)

if n == 1:
    print(p)
elif p == 1:
    print(1)
else:
    ni = prime_factors(p)
    max_gcd = 0
    for i in range(len(ni)//2):
        shuffle(ni)
    #for ni_ in permutations(ni):
        array_list = list(np.array_split(np.roll(ni, 1), n))
        #array_list = list(np.array_split(ni_, n))
        prod_list = [np.prod(i) for i in array_list]
        # print(array_list)
        # print(prod_list)
        g = prod_list[0]
        for p in prod_list[1:]:
            g = gcd(g, p)
            # print(g)
        if g > max_gcd:
            max_gcd = g
    print(max_gcd)

Submission status: Runtime Error

Solution code:
n, p = list(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

fact = prime_factors(p)
if len(fact) <= 1:
    print(1)
    exit(1)
i = 0
print(fact)
while 1:
    if len(fact) == n:
        break
    if i >= len(fact):
        i = 0
    if len(fact) <= 1:
        print(1)
        exit(1)
    fact[i] = fact[i]*fact[-1]
    fact.pop()
    i += 1
print(min(fact))

Submission status: Runtime Error

Solution code:
np = input().split(" ")
n = int(np[0])
p = int(np[1])

elem_list = []

def search(n, p, elem_list, i):
  elem = i ** n
  while elem <= p:
    elem = i ** n
    if p % elem == 0:
      elem_list.append(elem)
      return search(n, int(p / elem), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
elif p == 1:
  print(1)
#elif n > p:
  #print(1)
else:
  import functools
  import operator
  elem_list = search(n, p, elem_list, 2)
  #print(elem_list)
  deles = []
  for e in elem_list:
    for f in elem_list:
        if e != f:
            if e % f == 0 or f % e == 0:
                dele = min(e,f)
                #print(dele)
                deles.append(dele)
  #print(deles)
  if len(deles) != 0:
    dele = list(set(deles))
    for e in dele:
      elem_list.remove(e)
    #print(elem_list)
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Runtime Error

Solution code:
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
if p==i and c+1 ==N:
  ans*=i
print(ans)

Submission status: Runtime Error

Solution code:
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
n,p = map(int,input().split())
a = callIsPrime(input_num=n)
c = 1
m = p**(1/n)
i = 0
while a[i]<=m:
    b = a[i]**n
    if p%b == 0:
        c *= a[i]
        p //= b
        if b>p:
            break
        while p%b == 0:
            c *= a[i]
            p //= b
        i += 1
        if b>p:
            break
    else:
        i += 1
print(c)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np


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

    if p == 1:
        print(1)

    else:
        x_val = int((p ** (1/n)) // 1) + 1
        x_list = np.array([x_val - i for i in range(x_val - 1)])
        x_list = x_list ** n

        dum = np.mod(p, x_list)
        print(x_val - (np.where(dum == 0)[0][0]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

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

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

Submission status: Runtime Error

Solution code:
np = input().split(" ")
n = int(np[0])
p = int(np[1])

elem_list = []

def search(n, p, elem_list, i):
  elem = i ** n
  while elem <= p:
    elem = i ** n
    if p % elem == 0:
      elem_list.append(elem)
      return search(n, int(p / elem), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
elif p == 1:
  print(1)
#elif n > p:
  #print(1)
else:
  import functools
  import operator
  elem_list = search(n, p, elem_list, 2)
  #print(elem_list)
  deles = []
  for e in elem_list:
    for f in elem_list:
        if e != f:
            if e % f == 0 or f % e == 0:
                dele = min(e,f)
                #print(dele)
                deles.append(dele)
  #print(dele)
  dele = list(set(deles))
  for e in dele:
    elem_list.remove(e)
  #print(elem_list)
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Runtime Error

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]]

primax = int(1e7) + 9 * int(1e6)
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)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)

Submission status: Runtime Error

Solution code:
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: Runtime Error

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

def yakusuSub(p,d,arr):
    if p==1:return arr
    if p/d==int(p/d):
        arr.append(d)
        return yakusuSub(p/d,d,arr)
    else:
        return yakusuSub(p,d+1,arr)

def yakusu(p):
    return yakusuSub(p,2,[])

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

y=yakusu(p)
ans=1
cnt=1
before=0
for i in y:
    if i==before:
        cnt+=1
    else:
        cnt=1       
    if cnt>=n:
        ans*=i
        cnt=1
    before=i
print(ans)

Submission status: Runtime Error

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]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)




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)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE

if P > 1e9 and debug != P and  debug < (P//2):
    raise "errror"
print(ans)

Submission status: Runtime Error

Solution code:
n, p = (int(i) for i in input().split())

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

print(ans)