shtirmann

Untitled

Feb 21st, 2023
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5.  
  6. int main() {
  7.   ll r;
  8.   cin >> r;
  9.   for (ll x = 1; x * x + x + 1 <= r; ++x) {
  10.     ll y = (r - ((x * x) + x + 1)) / (2 * x);
  11.     if (!x || !y) {
  12.       continue;
  13.     }
  14.     if ((x * x) + (2 * x * y) + x + 1 == r) {
  15.       cout << x << ' ' << y;
  16.       return 0;
  17.     }
  18.   }
  19.   cout << "NO";
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment