Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. typedef long long ll;
  6. typedef long double ld;
  7. const ll A = 911382323;
  8. const ll B = 972663749;
  9. const ll mod = 1e9 + 7;
  10.  
  11. const int N = 1e5 + 500;
  12. const int M = 5e5 + 500;
  13.  
  14. #define F first
  15. #define S second
  16. #define PB push_back
  17. #define all(v) (v).begin(), (v).end()
  18. #define sz(x) (int)x.size()
  19. //#define endl '\n'
  20.  
  21. int dd[4][2]={{-1,0},{1,0},{0,1},{0,-1}};
  22.  
  23.  
  24. int main()
  25. {
  26. ios_base::sync_with_stdio(0); cin.tie(0);
  27. cout<<fixed<<setprecision(20);
  28. //freopen("input.txt", "r", stdin);
  29. //freopen("output.txt", "w", stdout);
  30. ll n; cin>>n;
  31. ll x = sqrt(n);
  32. if(x & 1){
  33. ll i = x,j = x;
  34. ll k = n - x * x;
  35. if(k >= 3){
  36. i++; k -= 3;
  37. i -= ((k/2) & 1?1:0);
  38. j -= (k+1) / 2;
  39. }else if(k == 1){
  40. j++;
  41. }else if(k == 2){
  42. i++, j++;
  43. }
  44. if(!((x/2) & 1)) swap(i,j);
  45. cout<<i<<' '<<j<<endl;
  46. }else{
  47. ll i = 1,j = x;
  48. ll k = n - x * x;
  49. i += (k-1) / 2;
  50. j += (k?((k/2) & 1?2:1):0);
  51. if(!((x/2) & 1)) swap(i,j);
  52. cout<<i<<' '<<j<<endl;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement