Advertisement
danya11334

Untitled

Feb 20th, 2025
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     ios::sync_with_stdio(false);
  6.     cin.tie(nullptr);
  7.  
  8.     long long n;
  9.     cin >> n;
  10.  
  11.     bool found = false;
  12.     for (long long a = 1; a * a <= n; ++a) {
  13.         long long r = n - a * a;
  14.         if (r <= 0) break;
  15.         long long b = (long long)floor(sqrt(r));
  16.         if (b > 0 && b * b == r) {
  17.             cout << a << " " << b << "\n";
  18.             found = true;
  19.             break;
  20.         }
  21.     }
  22.  
  23.     if (!found) {
  24.         cout << "NO" << "\n";
  25.     }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement