• Source
    1. #include<bits/stdc++.h>
    2.  
    3. using namespace std;
    4.  
    5. int main()
    6. {
    7. long long n,row,col,row_or_col,from,to;
    8.  
    9. double store;
    10.  
    11. while(scanf("%lld",&n)&&n)
    12. {
    13. store = n;
    14.  
    15. row_or_col = ceil(sqrt(store));
    16.  
    17. from = row_or_col-1;
    18.  
    19. from = (from*from)+1;
    20.  
    21. to = from-1+row_or_col;
    22.  
    23. if(row_or_col%2==0)
    24. {
    25. if(n>=from && n<=to)
    26. {
    27. row = row_or_col;
    28.  
    29. col = (n-from)+1;
    30. }
    31. else
    32. {
    33. col = row_or_col;
    34.  
    35. row = (row_or_col*row_or_col)-n+1;
    36. }
    37. }
    38. else
    39. {
    40. if(n>=from && n<=to)
    41. {
    42. col = row_or_col;
    43.  
    44. row = (n-from)+1;
    45. }
    46. else
    47. {
    48. row = row_or_col;
    49.  
    50. col = (row_or_col*row_or_col)-n+1;
    51. }
    52. }
    53.  
    54. printf("%lld %lld\n",col,row);
    55. }
    56.  
    57. return 0;
    58. }