Here is the function that can check if a number num is power a anohter number base.
bool isPowerof(long long num, long long base)
{
long double log_num =log(num) / log(base);
if (fabs(log_num - round(log_num)) < 0.000001)
//if difference is less than 10^-5 then they are same number
{
return true;
}
else
{
return false;
}
}
This function can show accurate results if the number is num<=2^63 and in constant time. Here is a sample submission 169961565.




