fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int count_pairs(int n) {
  5. int count = 0;
  6. int sqrt_n = std::sqrt(n);
  7. for (int x = 1; x <= sqrt_n; x++) {
  8. int y = sqrt_n * sqrt_n - x * x;
  9. int sqrt_y = std::sqrt(y);
  10. if (sqrt_y * sqrt_y == y && x + sqrt_y == sqrt_n) {
  11. count++;
  12. }
  13. }
  14. return count;
  15. }
  16.  
  17. int main() {
  18. int n;
  19. std::cin >> n;
  20. std::cout << count_pairs(n) << std::endl;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5296KB
stdin
25
stdout
1