Advertisement
MaxObznyi

Q.22

Nov 17th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5.  
  6. void solve(long long n) {
  7. for (long long a = 1; a * a <= n; a++) {
  8. long long b = n - a * a;
  9. long long t = sqrt(b);
  10. if (t * t == b && b >= 0 && t >= a) {
  11. cout << a << ' ' << t << "\n";
  12. }
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. long long n;
  19. cin >> n;
  20. solve(n);
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement