[ACM]Q113: Power of Cryptography
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
namespace Q113
{
class Program
{
static private BigInteger _n, _p, _result; static private bool _ntof, _ptof;
static void Main(string[] args)
{
for (; ; )
{
labeln: Console.Write("n>>>");
_ntof = BigInteger.TryParse(Console.ReadLine(), out _n);
if (!_ntof) goto labeln;
labelp: Console.Write("p>>>");
_ptof = BigInteger.TryParse(Console.ReadLine(), out _p);
if (!_ptof) goto labelp;
for (BigInteger k = 1; k <= _p; k++)
{
_result = 1;
for (BigInteger i = 0; i < _n; i++)
{
_result *= k;
if (_result > _p) break;
}
if (_result == _p)
{
Console.WriteLine(k);
break;
}
}
}
}
}
}