fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. bool pPow(int x, int n) {
  5. int m = (int)pow(x, 1.0/n);
  6. if (x == pow(m, n))
  7. return true;
  8. /********************************/
  9. if (x == pow(m + 1, n))
  10. return true;
  11. /********************************/
  12. return false;
  13. }
  14.  
  15. int const y_ulimit = 10;
  16. int const n_ulimit = 10;
  17. int main() {
  18. /* y^n = x */
  19. for (int y = 2; y <= y_ulimit; y++) {
  20. int x = 1;
  21. for (int n = 1; n <= n_ulimit; n++) {
  22. x *= y;
  23. if (!pPow(x, n)) {
  24. std::cout << "pPow(" << x << "," << n <<") == false!!" << std::endl;
  25. std::cout << y << "^" << n << ": " << x << std::endl;
  26. }
  27. }
  28. }
  29. return 0;
  30. }
  31. /* end */
  32.  
Success #stdin #stdout 0s 5644KB
stdin
Standard input is empty
stdout
pPow(-808182895,10) == false!!
9^10: -808182895
pPow(1410065408,10) == false!!
10^10: 1410065408