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:
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
po=math.pow(P,(1/N))
for i in reversed(range(round(po,0)+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)

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(round(math.pow(P,(1/N))+1)):
    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 math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N))))):
    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 math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))):
    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:
N, P = (long(i) for i in input().split())
print(max([x for x in range(1,int(pow(P, 1/N))+1) if P%(x**N)==0]))

Submission status: Runtime Error

Solution code:
N, P = (int(i) for i in input().split())
print(max([x for x in range(1,long(pow(P, 1/N))+1) if P%(x**N)==0]))

Submission status: Runtime Error

Solution code:
N, P = (int(i) for i in input().split())
print(max([x for x in range(1,int(pow(P, 1/N))) if P%(x**N)==0]))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p)**(1/2))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Submission status: Runtime Error

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

lim = int(p) + 1

dic = {}

def my(N,newP=P,s=2):
    for i in range(s,lim+1):
        if newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP //= i
            s = i
            break
    
        if newP < i or i == lim+1:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
    my(N,newP,s)

my(N)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
i = round(P**(1/N))+1

if n == 1:
    print(P)

else:
    while i >= 1:
        if P % (i**N) == 0:
            print(i)
            break
        i -= 1

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

lim = int(p) + 1

dic = {}

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

my(N)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

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

factor = prime_factors(P)

res_fac = factor[:N]
rem_fac = factor[N:]

index = 0
for i in rem_fac:
    if len(res_fac)-1 < index:
        index = 0
    res_fac[index] *= i
    index += 1

print(gcd_list(res_fac))

Submission status: Runtime Error

Solution code:
saikyo = [int(i) for i in input().split()] 


number = int(saikyo[1])
bobo = int(saikyo[0])
i = 2
 
answer = ""
 
while number >= i:
    if number % i == 0:
        if answer == "":
            answer = str(i)
        else:
            answer = answer + " " + str(i)
        number /= i
    else:
        i += 1
 
a = [int(i) for i in answer.split()]

import collections

b = collections.Counter(a)
c = len(b)
d = [b.most_common()[i][1] // bobo for i in range(c)]

def remove_specified_values(arr, value):
    while value in arr:
        arr.remove(value)
remove_specified_values(d, 0)

e = len(d)
f = [b.most_common()[i][0] * d[i] for i in range(e)]

import functools
import operator


g = functools.reduce(operator.mul, f)
print(g)

Submission status: Runtime Error

Solution code:
saikyo = [int(i) for i in input().split()] 


number = int(saikyo[0])
bobo = int(saikyo[1])
i = 2
 
answer = ""
 
while number >= i:
    if number % i == 0:
        if answer == "":
            answer = str(i)
        else:
            answer = answer + " " + str(i)
        number /= i
    else:
        i += 1
 
a = [int(i) for i in answer.split()]

import collections

b = collections.Counter(a)
c = len(b)
d = [b.most_common()[i][1] // bobo for i in range(c)]

def remove_specified_values(arr, value):
    while value in arr:
        arr.remove(value)
remove_specified_values(d, 0)

e = len(d)
f = [b.most_common()[i][0] * d[i] for i in range(e)]

import functools
import operator


g = functools.reduce(operator.mul, f)
print(g)

Submission status: Runtime Error

Solution code:
number = int(input())
bobo = int(input())
i = 2
 
answer = ""
 
while number >= i:
    if number % i == 0:
        if answer == "":
            answer = str(i)
        else:
            answer = answer + " " + str(i)
        number /= i
    else:
        i += 1
 
a = [int(i) for i in answer.split()]

import collections

b = collections.Counter(a)
c = len(b)
d = [b.most_common()[i][1] // bobo for i in range(c)]

def remove_specified_values(arr, value):
    while value in arr:
        arr.remove(value)
remove_specified_values(d, 0)

e = len(d)
f = [b.most_common()[i][0] * d[i] for i in range(e)]

import functools
import operator


g = functools.reduce(operator.mul, f)
print(g)

Submission status: Runtime Error

Solution code:
import math

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


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

print(result)

Submission status: Runtime Error

Solution code:
import math

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


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

print(result)

Submission status: Runtime Error

Solution code:
from sys import stdin
from functools import reduce
from operator import mul
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

def primeFactors(n):
    factors = []
    apnd = factors.append
    while n >= 4:
        if n % 2:
            break
        else:
            n //= 2
            apnd(2)
    i = 3
    while n >= i * i:
        if n % i:
            i += 2
        else:
            n //= i
            apnd(i)
    apnd(n)
    return factors

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

    if N == 1:
        print(P)
        return
    an = primeFactors(P)
    l = len(an)
    if l < N:
        print(1)
        return

    ans = reduce(gcd, an)
    lst1 = []
    for i in range(N - 1):
        lst1.append(an[i] * an[l-1-i])
        lst2 = an[i+1:l-1-i]
    n = reduce(mul, lst2)
    lst1.append(n)
    ans = reduce(gcd, lst1)
    print(ans)

input = lambda: stdin.readline()
main()

Submission status: Runtime Error

Solution code:
number = int(input())
 
i = 2
 
answer = ""
 
while number >= i:
    if number % i == 0:
        if answer == "":
            answer = str(i)
        else:
            answer = answer + " " + str(i)
        number /= i
    else:
        i += 1
 
a = [int(i) for i in answer.split()]

import collections

b = collections.Counter(a)
c = len(b)
d = [b.most_common()[i][1] // 4 for i in range(c)]

def remove_specified_values(arr, value):
    while value in arr:
        arr.remove(value)
remove_specified_values(d, 0)

e = len(d)
f = [b.most_common()[i][0] * d[i] for i in range(e)]

import functools
import operator


g = functools.reduce(operator.mul, f)
print(g)