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

i = 2
plimes = []

if N == 1:
    print(P)
else:
    while(i <= math.sqrt(P)):
        if P % i == 0:
            P = P // i
            plimes.append(i)
        elif i == 2:
            i += 1
        else:
            i += 2
    plimes.append(P)


    resalt = 1
    j = 0

    while(len(plimes) > j):
        k =plimes.count(plimes[j])
        if k // N >= 1:
            resalt = resalt * plimes[j] * (k//N)
        j = j + k
    print(resalt)

Submission status: Wrong Answer

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

Solution code:
import math
n,p=map(int,input().split())
s=0
I=p
R=int(I)
l=[]
if p==1:
  print(1)
  exit()
prev=1
c=1
x=1
while s==0:
  for i in range(2,R+1):
    if I%i==0:
      I=I/i
      if I==1:
          s=1
      if prev==i:
        c+=1
      else:
        prev=i
        c=1
      if c>=n:
        x*=i
        c=1
      break
print(x)

Submission status: Wrong Answer

Solution code:

import collections

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    for i in range(2,int(n**0.5)+1):
        # print(pow(i, length),  n)
        if pow(i, length) > n:
            break
        if i > n or n == 1:
            break
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    soinnsuu = prime_factor(num, length)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)

Submission status: Wrong Answer

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

factor = []

p = 2
n = P
while p * p <= n:
    c = 0

    while n % p == 0:
        c += 1
        n //= p
    if c > 0:
        factor.append((p, c))
    p += 1

ans = 1
for key, count in factor:
    c = count
    while c >= N:
        ans *= key
        c -= N

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,P=map(int,input().split())
a=math.sqrt(P)
if N > 3 :
    b=math.sqrt(a)
    a=b

res=1
for i in range(1,int(a)+1):
    if P % i**N: continue
    res = i

print(res)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
p = 0
if s[1] < 8:
    print(1)
elif s[0] ==1:
    print(s[1])
else:
    k = 2
    while k**s[0] < s[1]:
        if s[1] % k**s[0] == 0:
            p = k
        k+=1
       
    print(p)

Submission status: Wrong Answer

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 / (i ** n)), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
elif p == 1:
  print(1)
else:
  import functools
  import operator
  elem_list = search(n, p, elem_list, 1)
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Wrong Answer

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

print(s)

Submission status: Wrong Answer

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

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

PS = primes(1000000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
print(result)

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 % math.pow(i, N) == 0:
        print(i)
        break
    i -= 1

Submission status: Wrong Answer

Solution code:
import math
N, P = map(int, input().split())
n = 1
p = math.ceil(P ** (1/N))
for i in range(2,p):
  while True:
    if P % (i ** N) == 0:
      n *= i
      P = P / (i ** N)
    else:
      break
  if P <= i ** N:
    break 
    
print(n)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
n_list = []
num = int(p**(1/n))
for i in range(1,num+1):
    if p%(i**n) == 0:
        n_list.append(i)
print(max(n_list))

Submission status: Wrong Answer

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

print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

result = 1

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

for i in range(p):

    compare = num2 ** n

    if p % compare == 0:
        result = num2
        break

    a = int(p / compare)

    if a == 0:
        num2 -= 1
    else:
        num2 = int((p/(a+1)) ** (1/n))

print(result)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections

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

def soinsuu(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

    return result

answer = 1
for k, v in collections.Counter(soinsuu(P)).items():
    if v >= N:
        answer *= k * (v // N)

print(answer)

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd
from functools import reduce


# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0  # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


n, p = map(int, input().split())
res = 1
if n == 1:
    print(p)
else:
    divide = math.ceil(pow(p, 1 / n))
    for i in reversed(range(1, divide + 1)):
        if p % (i ** (n - 1)) == 0:
            tmp = i ** (n - 1)
            tmp2 = p // i ** (n - 1)
            res = max(res, gcd(i, tmp2))
print(res)

Submission status: Wrong Answer

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

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

PS = primes(100000)
def factorint(x):
  d = {}
  for k in PS:
    if(x % k== 0):
      m = 1
      while(x % (k**m) == 0):
        m += 1
      d[k] = m - 1
      x = x / (k ** (m - 1))
      if x == 1:
        break
  return d

fac = factorint(p)
result = 1
for i,j in fac.items():
  result *= i **math.floor(j/n)
print(result)

Submission status: Wrong Answer

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

if p == 1:
    print(1)
else:
    while s == 0:
        for i in range(2,a+1):
            if p % i == 0:
                p = p / i
                if p == 1:
                    s = 1
                
                if i not in b:
                    b[i] = 1
                else:
                    b[i] += 1
                
                break

    ans = 1
    for k,v in b.items():
        if v >= n:
            ans *= k
    print(ans)

Submission status: Wrong Answer

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

a = 1
b = 1

if N == 1 :
	print(P)
else:
	while P >= a**N:
		if P % a**N == 0:
			P /= a**N
			b *= a
		a += 1
	print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    ans = []
    for i in range(1, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return sorted(ans)

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

ans = 1
for i in facts:
	if i**n <= p:
		ans = max(ans, i)
print(ans)

Submission status: Wrong Answer

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

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

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

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

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

if N==1:
    print(P)
    exit(0)
flag=1
anser=[1]
end=int(P**(1/N))+1
if P%(2**N)==0:
    flag=2
for i in range(3,end+1,2):
    if P%(i**N)==0:
        anser.append(i)
print(anser[-1]*flag)

Submission status: Wrong Answer

Solution code:
n,p = [int(i) for i in input().split()]
ass = 1
for i in range(2,int(p**0.5)+1):
 while p % (i**n)==0:
  ass*=i
  p = p//(i**n)
print(ass)

Submission status: Wrong Answer

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:
        bobo.append(k)
for j in bobo:
    if P/(j**N) in yakusu:
        ans=int(j)
print(ans)

Submission status: Wrong Answer

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)
      if i == 1:
      	return search(n, int(p / (i ** n)), elem_list, i + 1)
      else:
        return search(n, int(p / (i ** n)), elem_list, i)
    i += 1
  return elem_list

if n == 1:
  print(p)
else:
  elem_list = search(n, p, elem_list, 1)
  import functools
  import operator
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Wrong Answer

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

i=2
gcd=1
p=1024*1024*1024
if(n>40):
    print(1)
elif(n==1):
    print(p)
else:
    while((i**n)<=p):
        if(p%(i**n)==0):
            #print(i)
            gcd*=i
            p/=(i**n)
            i-=1
        i+=1
        
    print(gcd)

Submission status: Wrong Answer

Solution code:
import math

def factoring(x):
    ans = []
    for i in range(1, int(math.sqrt(x))+1):
        if x%i == 0:
            ans.append(i)
            ans.append(x // i)
    return sorted(ans)

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

ans = 1
for i in facts:
	if i**n <= p:
		print(ans)
		ans = max(ans, i)
print(ans)

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=0
gcd=1
n,p=map(int,input().split())
a=prime_decomposition(p)

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

Submission status: Wrong Answer

Solution code:
import math
import copy

N,P= map( int , raw_input().split() )
Po=copy.deepcopy(P)


D={}
p=math.sqrt(P)

x=2
cnt=0
while x<p:
	if P%x==0:
		P/=x
		cnt+=1
	else:
		if cnt>0:
			D[x]=cnt
		x+=1
		cnt=0
else:
	if cnt>1:
		D[x]=cnt



if len(D)==0:
	print Po	
else:
	ans=1
	for x,y in D.items():
		if y>=N:
			ans*= x**(y/N)
	print ans

Submission status: Wrong Answer

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 in l:
    ans *= i
if len(j) == 0:
    j = [1]
print(ans**min(j))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
n_list = []
num = int(p**(1/n))
for i in range(1,num+1):
    if p%(i**n) == 0:
        n_list.append(i)

#print(n_list)

print(max(n_list))

Submission status: Wrong Answer

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

ans = 1
if N == 1:
    print(P)
else:
    for k in range(1, 100000):
        kn = pow(k, N)
        if (P % kn) == 0:
            ans = k
        if P < kn:
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
def prime_decomposition(n):
    i = 2
    dic = {}
    while i * i <= n:
        while n % i == 0:
            n /= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
    if n > 1:
        # print(n)
        dic[int(n)] = 1
        # print(dic)
    return dic

N, P = map(int, input().split())
d = prime_decomposition(P)
# print(d)
ret = 1
for k, v in d.items():
    if v >= N:
        ret *= k
print(ret)

Submission status: Wrong Answer

Solution code:
import collections

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

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

c = collections.Counter(cal(P)).most_common()

for x, y in c:
    if y >= N:
        ans *= x*(y//N)
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

while True:
    if P % math.pow(i, N) == 0:
        print(i)
        break
    i -= 1

Submission status: Wrong Answer

Solution code:
# import math
# import random
import collections

# length, num = list(map(int, input().split()))

# def make_seed():
#     global length
#     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]
#     for i in range(len(seed_primes)):
#         seed_primes[i] = pow(seed_primes[i], length)
#     return seed_primes
#
#
# class Prime:
#     seed_primes = make_seed()
#     # print(seed_primes)
#
#     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
#         # print(self.seed_primes[:_get_range(num)])
#
#         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):
#         global length
#         """
#         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)
#
#         d = pow(d, length)
#
#         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)
#             print(factor)
#
#             primes.setdefault(factor, 0)
#             primes[factor] += 1
#
#             n //= factor
#
#         print(primes)
#
#         return primes

# def make_seed(num):
#     global seed_primes
#     for i in range(len(seed_primes)):
#         seed_primes[i] = pow(seed_primes[i], num)

#nの素因数分解(O(n**0.5)
def prime_factor(n):
    ass = collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        # i = pow(i, num)
        while n % i==0:
            # ass.append(i)
            ass[i] += 1
            n = n//i
    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))
    # global length, num

    # make_seed(num)
    # prime = Prime()
    # soinnsuu = prime.find_factors(num)
    soinnsuu = prime_factor(num)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
        # if soinnsuu[data] >= length:
        # ans *= data
    print(ans)

Submission status: Wrong Answer

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 / (i ** n)), elem_list, i + 1)
    i += 1
  return elem_list

if n == 1:
  print(p)
else:
  elem_list = search(n, p, elem_list, 1)
  import functools
  import operator
  result = int(functools.reduce(operator.mul, elem_list) ** (1/n))
  print(result)

Submission status: Wrong Answer

Solution code:
import math
def make_prime_list(num):
    if num < 2:
        return []
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break
        
        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0
    return [prime for prime in prime_list if prime != 0]

def prime_factorization(num):
    if num <= 1:
        return {1 : 1}
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1
        return dict_counter




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

    d = prime_factorization(P)

    cnt = 1

    for key, value in d.items():
        if value >= N:
            cnt *= key
    if N == 1:
        print(P)
    else:
        print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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) - 70000000 #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: Wrong Answer

Solution code:
import math
N, P = map(int, input().split())
n = 1
j = 1
p = math.ceil(P ** (1/N))
for i in range(2,p):
  while True:
    if P % (i ** N) == 0:
      n *= i
      P = P / (i ** N)
    else:
      break
    
print(n)

Submission status: Wrong Answer

Solution code:
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
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
print(int(res))

Submission status: Wrong Answer

Solution code:
import math

N,P=map(int,input().split())
a=math.sqrt(P)

res=1
for i in range(1,int(a)):
    if P % i**N: continue
    res = i

print(res)

Submission status: Wrong Answer

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

primelist=[]
powerlist=[]

p=2
while P >= p**N:        
    f = 0
    for q in primelist:
        if p % q == 0:
            f = 1
            break
    if f == 1:
        if p % 6 == 1:
            p += 4
        else:
            p += 2
        continue
    else:
        k = 0
        while P % (p**N) == 0:
            P //= (p**N)
            k += 1
        primelist.append(p)
        powerlist.append(k)
        if p % 6 == 1:
            p += 4
        elif p % 6 == 5:
            p += 2
        else:
            p += 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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


s = 1

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

print(s*2)

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)

pp = []

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

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

if len(pp) == 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)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
L =[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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
H = []
def f(x):
    k = 1
    while True:
        d = x**(k*n)

        if p % d == 0:
            k += 1
        else:
            k -= 1
            break

    if k != 0:
        H.append(x**k)
for i in range(len(L)):
    f(L[i])

gcd_ = 1
for i in range(len(H)):
    gcd_ = gcd_ *H[i]
print(gcd_)

Submission status: Wrong Answer

Solution code:
import collections

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

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


c = collections.Counter(factors)

pr=1
for f1,f2 in c.items():
    if f2/n>=1:
        pr*=f1*int(f2/n)
        
print(pr)

Submission status: Wrong Answer

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

i = 2
factors = []
factor_sub = set()
if p > 1:
    while i * i <= p:
        if p % i:
            i += 1
        else:
            p //=i
            factors.append(i)
            factor_sub.add(i)
    if p > 1:
        factors.append(p)
    if len(factors) < n:
        print('1')
    else:
        ans = 1
        for c in factor_sub:
            temp = factors.count(c)
            while temp >= n:
                ans *= c
                temp -= n
        print(int(ans))
else:
    print('1')

Submission status: Wrong Answer

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

ans = 1
if N == 1:
    print(ans)
else:
    for k in range(1, 10000000):
        kn = pow(k, N)
        if (P % kn) == 0:
            ans = k
        if P < kn:
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
def prime_decomposition(n):
    i = 2
    dic = {}
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
    if n > 1:
        # print(n)
        dic[n] = 1
        # print(dic)
    return dic

N, P = map(int, input().split())
d = prime_decomposition(P)
ret = 1
for k, v in d.items():
    if v >= N:
        ret *= k
print(ret)

Submission status: Wrong Answer

Solution code:
import math

N=4
P=972439611840
a=math.sqrt(P)

res=1
for i in range(1,int(a)):
    if P % i**N: continue
    res = i

print(res)