Advertisement
smatskevich

Solutions3

Jan 9th, 2022
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <map>
  5. #include <set>
  6. #include <string>
  7. #include <tuple>
  8. #include <unordered_map>
  9. #include <unordered_set>
  10. #include <vector>
  11.  
  12. typedef long long ll;
  13. using namespace std;
  14.  
  15. int main() {
  16.   ios::sync_with_stdio(false);
  17.   cin.tie(nullptr);
  18.  
  19.   ll n = 0;
  20.   cin >> n;
  21.   --n;
  22.   ll s = sqrt(n);
  23.   // Требуется проверить на точность вычисления.
  24.   if ((s + 1) * (s + 1) <= n) ++s;
  25.   else if (s * s > n) --s;
  26.   n -= s * s;
  27.  
  28.   if (s % 2 == 1) {
  29.     if (n <= s) cout << n + 1 << " " << s + 1 << endl;
  30.     else cout << s + 1 << " " << s - (n - s) + 1 << endl;
  31.   } else {
  32.     if (n <= s) cout << s + 1 << " " << n + 1 << endl;
  33.     else cout << s - (n - s) + 1 << " " << s + 1 << endl;
  34.   }
  35.  
  36.   return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement