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:
def main():
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append([i, count])
        if temp != 1:
            result.append([int(temp), 1])
        if result == []:
            result.append([num, 1])
        return result

    n, p = map(int, input().split())
    factors = factorization(p)
    ans = 1
    for f, v in factors:
        ans *= f * (v // n) if v >= n else 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
if m!= 1:
    L.append(m)
#L.append(1)

from collections import Counter
L = Counter(L)

cnt = 1
for k,v in L.items():
    if v >= n:
        cnt *=k*(v//n)
print(cnt)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    """素因数分解する

    下記より引用いたしました。
    https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8

    Parameters
    ----------
    n : integer
        対象の数

    Returns
    -------
    list
        素因数分解のリスト
        list[素数][n乗]
    """
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N, P = map(int, input().split())
fact_li = factorization(P)
ans = 1
for i in range(len(fact_li)):
    if fact_li[i][1] >= N:
        cnt = fact_li[i][1] // N
        ans *= fact_li[i][0] * cnt
print(ans)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    """素因数分解する

    下記より引用いたしました。
    https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8

    Parameters
    ----------
    n : integer
        対象の数

    Returns
    -------
    list
        素因数分解のリスト
        list[素数][n乗]
    """
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N, P = map(int, input().split())
fact_li = factorization(P)
ans = 1
for i in range(len(fact_li)):
    if fact_li[i][1] >= N:
        ans *= fact_li[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def p_fact(n,a):
  m=n
  i=2
  a.append(1)
  while n>1:
    if i>m**.5:
      a.append(n)
      break
    if n%i==0:
      n//=i
      a.append(i)
    else:i+=1  
  return a
n,m=map(int,input().split())
a=Counter(p_fact(m,[]))
b=a.values()
c=a.keys()
ans=1
for i,j in zip(c,b):
  if j>=n:ans*=i
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, p = [int(x) for x in input().split()]
    i = 2
    pc = p
    f = defaultdict(int)
    while i * i <= pc:
        while p % i == 0:
            f[i] += 1
            p //= i
        i += 1
    if p != 1:
        f[p] += 1
    ans = 1
    for d in f:
        x = f[d] // n
        if x:
            ans *= x * d
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Wrong Answer

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


div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
if m!= 1:
    L.append(m)

from collections import Counter
L = Counter(L)

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

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N,P = map(int,input().split())
ans = 1
for i in factorization(P):
  if i[1] >= N:
    ans *= i[0]
print(ans)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

fact_P = factorization(P)

ans = 1
for i in range(len(fact_P)):
    now = fact_P[i]
    tmp = now[1]//N
    if tmp > 0:
        ans *= now[0] * tmp
    
print(ans)

Submission status: Wrong Answer

Solution code:
# なんか問題文とサンプル読んでいくと「Pを素因数分解してN個で割り振る」みたいな感じかと思う
n, p = map(int, input().split())


def div_primes(x):
    ret = {}
    for i in range(2, int(x**0.5) + 1):
        tmp = 0
        while x % i == 0:
            tmp += 1
            x //= i
        if tmp > 0:
            ret[i] = tmp

    if x > 1:
        ret[x] = 1
    return ret


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

Submission status: Wrong Answer

Solution code:
def PrimeFactorize(num):
    ret = dict()
    while num % 2 == 0:
        ret.setdefault(2, 0)
        ret[2] = ret[2] + 1
        num //= 2
    prime = 3
    while prime * prime <= num:
        if num % prime == 0:
            ret.setdefault(prime, 0)
            ret[prime] =ret[prime] + 1
            num //= prime
        else:
            prime += 2
    if num != 1:
        ret.setdefault(num, 0)
        ret[num] = ret[num] + 1
    
    return ret

def Main():
    n, p = map(int, input().split())    
    prime_list = PrimeFactorize(p)
    ans = 1
    for key, val in prime_list.items():
        if val >= n:
            ans *= key
    print(ans)

if __name__ == "__main__":
    Main()

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

temp=factorization(p)
ans=1
for i in range(len(temp)):
  if temp[i][1]>=n:
    ans=ans*temp[i][0]
print(ans)

Submission status: Wrong Answer

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

#xの約数を列挙する
def divisor(x):
    ans=set([])
    i=1
    while(i*i<=x):
        if(x%i==0):
            ans.add(i)
            ans.add(x//i)
        i+=1
    ans=sorted(list(ans))
    return ans


#xの素因数分解
def prime_factorization(x):
    ans={}
    divisors=divisor(x)
    xi=x
    for di in divisors:
        if(xi==1):
            break
        elif(di<=1):
            continue
        else:
            dj=0
            while(xi%di==0 and xi!=1):
                xi//=di
                dj+=1
            if(dj>0):
                ans[di]=dj
    return ans

pf=prime_factorization(p)
#print(pf)
ans=1
for k,v in pf.items():
    if(v>=n):
        ans*=(k*(v//n))
print(ans)

Submission status: Wrong Answer

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

#xの約数を列挙する
def divisor(x):
    ans=set([])
    i=1
    while(i*i<=x):
        if(x%i==0):
            ans.add(i)
            ans.add(x//i)
        i+=1
    ans=sorted(list(ans))
    return ans


#xの素因数分解
def prime_factorization(x):
    ans={}
    divisors=divisor(x)
    xi=x
    for di in divisors:
        if(di<=1):
            continue
        else:
            dj=0
            while(xi%di==0 and xi!=1):
                xi//=di
                dj+=1
            ans[di]=dj
    return ans

pf=prime_factorization(p)
ans=1
for k,v in pf.items():
    if(v>=n):
        ans*=(k*(v//n))
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(w) for w in input().split()]


if n == 1:
    ans = n
else:
    ans = 1
    i = 2
    while i <= int(p ** (1 / n) / ans):
        while (p / ans ** n) % i ** n == 0 and (p / ans ** n) > 0:
            ans *= i
        i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(w) for w in input().split()]


if n == 1:
    ans = n
else:
    ans = 1
    i = 2
    while i <= int(p ** (1 / n)):
        while (p / ans ** n) % i ** n == 0 and (p - ans ** n) > 0:
            ans *= i
        i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, p = [int(w) for w in input().split()]


if n == 1:
    print(p)
else:
    ans = 1
    i = 2
    while i <= int(p ** (1 / n) / ans):
        while (p / ans ** n) % i ** n == 0 and (p - ans ** n) > 0:
            ans *= i
        i += 1
    print(ans)

Submission status: Wrong Answer

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
s = factorization(p)

for valu, num in s:
    if num >= n:
        ans *= valu
print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(m)
    exit()
    
div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
L.append(m)
#print(L)
if n >= len(L):
    print(1)
    exit()
    
from collections import Counter
L = Counter(L)

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1:
    print(m)
    exit()
    
div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
L.append(m)
#print(L)
from collections import Counter
L = Counter(L)

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

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
def m():
    N, P = map(int, input().split())
    if N == 1:
        return P
    x = prime_factorize(P)
    a = 1
    c = Counter(x)
    ans = [1]
    for k, v in c.items():
        tmp = v // N
        if tmp != 0:
            ans.append(k*tmp)


    for i in ans: a*=i
    return a


print(m())

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
def m():
    N, P = map(int, input().split())
    if N == 1:
        return P
    x = prime_factorize(P)
    a = 1
    c = Counter(x)
    ans = [1]
    for k, v in c.items():
        if v >= N: ans.append(k)


    for i in ans: a*=i
    return a


print(m())

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n,p=map(int,input().split())
prime_list = [x[0] for x in factorization(p) if x[1]>=n]
ans = 1
for i in prime_list:
  ans*=i
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=factorization(p) 
ans=1
for i in range(len(a)):
    if n<=a[i][1]:
        ans=ans*a[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factorization(n): #nを素因数分解する
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i,cnt])

    if temp!=1:
        arr.append([temp,1])

#    if arr==[]:
#        arr.append([n, 1])  #n=1でarr=[1,1]としたいとき

    return arr

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

a=factorization(p)
#print(a)
ans=1
for i in range(len(a)):
    if(a[i][1]>=n):
        ans*=a[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr


def main():
    input = stdin.buffer.readline
    n, p = map(int, input().split())
    f = factorization(p)
    ans = 1
    for k in f:
        if f[k] >= n:
            ans *= (f[k] // n) * k
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main2():
    n,p=map(int, input().split())
    lis = factorization(p)
    lis.sort(key=lambda x:x[1], reverse = True)
    i = 0
    res = 1
    print(lis)
    while(i<len(lis) and lis[i][1]>=n):
        print(lis[i])
        res = lis[i][0]**(lis[i][1]//n)*res
        i+=1
    print(res)

if __name__ == '__main__':
    main2()

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main2():
    n,p=map(int, input().split())
    lis = factorization(p)
    lis.sort(key=lambda x:x[1], reverse = True)
    i = 0
    res = 1
    while(i<len(lis) and lis[i][1]>=n):
        res = lis[i][0]*(lis[i][1]//n)*res
        i+=1
    print(res)

if __name__ == '__main__':
    main2()

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main2():
    n,p=map(int, input().split())
    lis = factorization(p)
    lis.sort(key=lambda x:x[1], reverse = True)
    i = 0
    res = 1
    while(i<len(lis) and lis[i][1]>=n):
        res = lis[i][0]*res
        i+=1
    print(res)

if __name__ == '__main__':
    main2()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math
def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
d = defaultdict(int)
for i in trial_division(P):
    d[i] += 1
ans = []
for key in d.keys():
    if d[key] >= N:
        ans.append(key)
ans2 = 1
for i in ans:
    ans2 *= i
print(ans2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math
def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a
N, P = map(int, input().split())
d = defaultdict(int)
for i in trial_division(P):
    d[i] += 1
ans = []
for key in d.keys():
    if d[key] >= N:
        ans.append(key)
ans2 = 1
for i in ans:
    ans2 *= i
print(ans2)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  elif f*f>p:
    break
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  else:
      f+=2
c=Counter(a)
ans=1
print(c)
for k,v in c.items():
  if v>=n:
    ans*=k
print(ans)

Submission status: Wrong Answer

Solution code:
def fact(A):
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)
n,p = map(int,input().split())
lis = fact(p)
L = list(set(lis))
import collections
c = collections.Counter(lis)
ans = 1
for x in L:
    if c[x] >= n:
        ans *= c[x]//n*x
print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def integer_factorization(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    return prime_count

def main():
    N, P = LI()
    d = integer_factorization(P)
    ans = 1
    for k, v in d.items():
        if v // N >= 1:
            ans *= k * (v // N)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def factor(n):
    d = collections.defaultdict(int)
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            d[i] += 1
    if n > 1:
        d[n] += 1
    return d

def main():
    N, P = LI()
    d = factor(P)
    ans = 1
    for k, v in d.items():
        if v >= N:
            ans *= k * (v // N)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def factor(n):
    d = collections.defaultdict(int)
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            d[i] += 1
    if n > 1:
        d[n] += 1
    return d

def main():
    N, P = LI()
    d = factor(P)
    ans = 1
    for k, v in d.items():
        if v >= N:
            ans *= k
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
def main():
    n, p = list(map(int, input().split()))
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append([i, count])
        if temp != 1:
            result.append([int(temp), 1])
        if result == []:
            result.append([num, 1])
        return result
    ans = 1
    for (fac, cnt) in factorization(p):
        if cnt >= n:
            ans *= (fac * (cnt // n))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    import math
    class Eratos:
        def __init__(self, num):
            '''
            O(nlglgn) で num までの素数判定テーブルを作る
            >>> e = Eratos(10)
            >>> e.table
            [False, False, True, True, False, True, False, True, False, False, False]
            '''
            assert(num >= 1)
            self.table_max = num
            # self.table[i] は i が素数かどうかを示す (bool)
            self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
            for i in range(2, int(math.sqrt(num)) + 1):
                if self.table[i]:
                    for j in range(i ** 2, num + 1, i):    # i**2 からスタートすることで定数倍高速化できる
                        self.table[j] = False
        
        def is_prime(self, num):
            '''
            O(1) で素数判定を行う
            >>> e = Eratos(100)
            >>> [i for i in range(1, 101) if e.is_prime(i)]
            [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]
            '''
            assert(num >= 1)
            if num > self.table_max:
                raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
            return self.table[num]
        
        def prime_factorize(self, num):
            '''
            O(√n) で素因数分解を行う
            >>> e = Eratos(10000)
            >>> e.prime_factorize(6552)
            {2: 3, 3: 2, 7: 1, 13: 1}
            '''
            assert(num >= 1)
            if int(math.sqrt(num)) > self.table_max:
                raise ValueError('Eratos.prime_factorize(): exceed prime table size. got {}'.format(num))
            # 素因数分解の結果を記録する辞書        
            factorized_dict = dict()
            candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
            # n について、√n 以下の素数で割り続けると最後には 1 or 素数となる
            # 背理法を考えれば自明 (残された数が √n より上の素数の積であると仮定。これは自明に n を超えるため矛盾)
            for p in candidate_prime_numbers:
                if num == 1:    # これ以上調査は無意味
                    break
                if num % p == 0:
                    cnt = 0
                    while num % p == 0:
                        num //= p
                        cnt += 1
                    factorized_dict[p] = cnt
            if num != 1:
                factorized_dict[num] = 1
            return factorized_dict
        
    
    n, p = mi()
    e = Eratos(10 ** 6 + 1)
    if p == 1:
        print(1)
    else:
        d = e.prime_factorize(p)
        gcd = 1
        for k, v in d.items():
            if v >= n:
                gcd *= k * (v // n)
        print(gcd)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

div = 2
L = []
i = 1
while div <= int(m**0.5)+1:
    while m%div == 0:
        m //=div
        L.append(div)
    div +=1
L.append(m)

from collections import Counter
L = Counter(L)

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

Submission status: Wrong Answer

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

p_nums = factorization(p)

ans = 1

for i, j in p_nums:
    if j >= n:
        ans *= i * (j // n)
print(ans)

Submission status: Wrong Answer

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

p_nums = factorization(p)

ans = 1

for i, j in p_nums:
    if j >= n:
        ans *= i

print(ans)