// The cube root is a whole number. For example, 27 is a perfect cube, as ∛27 or (27)**1/3 = 3
#include <iostream>
#include <string>
#include <cmath>
bool isPerfectCubeRoot(int x) {
x = std::abs(x);
int cubeRoot = static_cast<int>(std::round(std::pow(x, 1.0 / 3.0)));
return std::pow(cubeRoot, 3) == x;
}
int main() {
std::wcout << isPerfectCubeRoot(16) << std::endl;
std::wcout << isPerfectCubeRoot(64) << std::endl;
std::wcout << isPerfectCubeRoot(27) << std::endl;
std::wcout << isPerfectCubeRoot(25) << std::endl;
std::wcout << isPerfectCubeRoot(-64) << std::endl;
std::wcout << isPerfectCubeRoot(-27) << std::endl;
std::wcout << isPerfectCubeRoot(729) << std::endl;
}
/*
run:
0
1
1
0
1
1
1
*/