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

x = 1
cd = 1
while x**N < P:
    if P%(x**N) == 0:
        cd *= x
    x += 2
print(cd)

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 == 0:
                    continue
                if z != 1:
                    if z ** (n - 1) * i > p:
                        continue
                    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:
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:
        x = count // N
        num *= i**x
        break

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

print(num)

Submission status: Wrong Answer

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

gcd = 1
tmp_P = P

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

print(gcd)

Submission status: Wrong Answer

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


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

    if n == 1:
        print(p)
    elif p == 1:
        print(1)
    else:
        x_val = math.floor((p ** (1/n)))

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

        print(x_val)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
N,P = [int(x) for x in input().split()]

n = 2    
while n**N <= P/2:
    n += 1
list = list(range(n))

for i in range(n):
    if list[i] == 1 or list[i] == 0:
        continue
    if P % (i**N) != 0:
        a = int(max(list)/i)
        for j in range(a+1):
            list[i*j] = 1

print(max(list))

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
if c2 == 0:
    c = 1
else:
    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())

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

Submission status: Wrong Answer

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

pp = p
# 2のべき乗チェック
count_2 = 0
while True:
    if pp % 2 == 0:
        pp = pp / 2
        count_2 += 1
    else:
        break

if count_2 >= n:
    result = 2
else:
    result = 1

p = p / (2 ** count_2)

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

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

Submission status: Wrong Answer

Solution code:
n,p=map(int, input().split())
ans=1
m=int(pow(p,1/n))+1
i=2
c=0
while(i<=p and i<int(pow(p,1/n))+1):
    if p % i == 0:
        p=p/i
        c=c+1
        if p % i != 0:
            #print('i**(c//n)=',i**(c//n))
            ans = ans * ( i**(c//n) )
            i=i+1
            c=0

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import math


def factorization(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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,P = map(int,input().split())
c = int(P**(1/N))
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if N>1 and is_prime(P):
    print(1)
    exit()
while(1):
    if P%(c**N)==0:
        print(c)
        exit()
    c-=1

Submission status: Wrong Answer

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:
        return R
    else:
        return 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: Wrong Answer

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


# def fun(n, p):
#     sosuu = [2]
#     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
#
#     return 1


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

    i = 2
    output = 1
    while i <= 1000000:
        if p % pow(i, n) == 0:
            output = i
        if i == 2:
            i += 1
        else:
            i += 2

    return output


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

    # output = fun(N, P)
    output = dummy(N, P)

    print(output)

Submission status: Wrong Answer

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

if P == 1 or N == 2:
    print(1)
elif N == 1:
    print(P)
else:
    import math

    sq_P = math.floor(math.sqrt(P))
    prim = []
    P_tmp=P

    for i in range(2,sq_P):
        r=0
        if P_tmp%i == 0:
            r+=1
            P_tmp=P/i
            while P_tmp%i==0:
                r+=1
                P_tmp=P_tmp/i
            prim.append([i,r])

    ans = 1
    for i in range(len(prim)):
        if prim[i][1]>=N:
            ans = ans * prim[i][0]

    print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

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

print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce
from operator import mul

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(mul,temp)))

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))
print(i)
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import math

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

table = [0] * (int(math.sqrt(p)) + 1)

pl = []
ans = 1

for i in range(2, int(math.sqrt(p)) + 1):
    if table[i] == 0:
        pl.append(i)
        for j in range(i + i, int(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

print(ans)

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(0,maxfac+1)[::-1]:
    p = i**N
    # print(P%p)
    if P%p == 0:
        print(i)
        break

Submission status: Wrong Answer

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


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

    if n == 1:
        print(p)
    elif p == 1:
        print(1)
    else:
        x_val = int((p ** (1/n)) // 1) + 1

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

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

        print(x_val)


if __name__ == "__main__":
    main()

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)

print(p)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def is_prime(num):
    for i in range(2, int(math.sqrt(num))+1):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False
    return True

for i in range(2,int(P**(1/2))+1):
    if is_prime(i) == True:
        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: Wrong Answer

Solution code:
#coding:utf-8

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

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

print(res)

Submission status: Wrong Answer

Solution code:
import sys
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)
    sys.exit()
y=prime_factors(p)

if len(y)==0:
    print(1)
    sys.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:
import math
N,M = map(int,input().split())
Max = 1
for m in range(1,int(M**(1/N))+1):
    if M%m**N == 0 and m <= M**(1/N) :
        if Max < m:
            Max = m
            
print(Max)

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
for i in range(1,b+1):#Pを1からbまで割って割り切れたものをリストcに格納

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

Submission status: Wrong Answer

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)

if b==1:
  print(p)

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: 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 == 0:
                    continue
                if z != 1:
                    v = (p % (z ** n))
                    #print(z, p)
                    if v == 0:
                        if v % n == 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())
b=0
a = int(pow(P, 1/N))
for i in range(1, a+1):
  if P % pow(a+1-i,N) == 0:
     b = a+1-i
     break

print(b)