Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5.  
  6.     long long N;
  7.     cin >> N;
  8.     long long l = 0, r = sqrt(N);
  9.     long long temp;
  10.     while (l <= r) {
  11.         temp = l * l + r * r;
  12.         if (temp == N) {
  13.             cout << l << " " << r;
  14.             return 0;
  15.         }
  16.         if (temp < N) l++;
  17.         else r--;
  18.     }
  19.     cout << "No solution";
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement