Advertisement
999ms

Untitled

Apr 13th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4.  
  5. int main() {
  6.     ll n;
  7.     cin>>n;
  8.     ll rnd = 0;
  9.     while(rnd * (4 * rnd + 3) <= n) rnd++;
  10.     rnd--;
  11.     int x = 0;
  12.     int y = rnd;
  13.     n -= rnd * (4 * rnd + 3);
  14.     while(n && x >-rnd-1) x--, n--;
  15.     while(n && y >-rnd-1) y--, n--;
  16.     while(n && x < rnd+1) x++, n--;
  17.     while(n && y < rnd+1) y++, n--;
  18.     while(n && x >     0) x++, n--;
  19.     cout<<x<<" "<<y<<endl;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement