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

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        long[] NP = LSRead();
        long N = NP[0], P = NP[1];
        if (P == 1) { Console.WriteLine(1); return; }
        if (N == 1) { Console.WriteLine(P); return; }
        var fac = new Factorization(P);
        var box = fac.Calc();
        Dictionary<long, long> dic = new Dictionary<long, long>();
        foreach (var l in box)
        {
            if (!dic.ContainsKey(l)) dic[l] = 1;
            else dic[l]++;
        }
        var sorted = dic.OrderByDescending(v => v.Key);
        long ans = 1;
        foreach (var v in sorted)
        {
            if (v.Value >= N)
            {
                ans *= (long)Math.Pow(v.Key, v.Value / N);
            }
        }
        Console.WriteLine(ans);
    }
}

public class Factorization
{
    private static long N;

    public Factorization(long n) { N = n; }

    //最大公約数を返す
    public static long GCD(long a, long b)
    {
        if (a < b) return GCD(b, a);
        long r;
        while (b != 0)
        {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    //素数判定
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        double root = Math.Sqrt(n);
        for (int i = 3; i <= root; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

    //試し割り
    private static int[] TryPrimes = new int[] { 2, 3, 5, 7, 11 };
    public long TryAllocation(long p)
    {
        long count = 0;
        while (N % p == 0)
        {
            count++;
            N /= p;
        }
        return count;
    }

    private int[] xi = new int[] { 13, 17, 19, 23, 29 };
    private long f(long x, int suffix)
    {
        return (xi[suffix % xi.Count()] * x + suffix) % N;
    }

    //nを分解
    public long PollardsRho(long n, int suffix = 0)
    {
        //素数を渡すと失敗するらしい
        if (IsPrime(n)) return n; //もう素数
        long x = 2, y = 2, d = 1;
        while (d == 1)
        {
            x = f(x, suffix);
            y = f(f(y, suffix), suffix);
            d = GCD(Math.Abs(x - y), n);
        }
        if (d == n)
        {
            //f(x)を変えて試す
            return PollardsRho(n, suffix + 1);
        }
        return d;
    }

    public IEnumerable<long> Calc()
    {
        //小さな素因数の計算
        foreach (var prime in TryPrimes)
        {
            var box = TryAllocation(prime);
            for (int i = 0; i < box; i++) yield return prime;
        }

        //残りをRhoで解く
        while (true)
        {
            if (N == 1) break;
            var ret = PollardsRho(N);
            yield return ret;
            N /= ret;
        }
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}