Pabon_SEC

Count on Cantor

May 29th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     long long n,diag_pos,print_n,lob,hor;
  8.  
  9.     while(scanf("%lld",&n)!=EOF)
  10.     {
  11.         print_n = n;
  12.  
  13.         for(diag_pos=1;n>diag_pos;diag_pos++)
  14.         {
  15.             n-=diag_pos;
  16.         }
  17.  
  18.         if(diag_pos%2)
  19.         {
  20.             lob = diag_pos - n + 1;
  21.         }
  22.         else
  23.         {
  24.             lob = n;
  25.         }
  26.  
  27.         hor = diag_pos+1-lob;
  28.  
  29.         printf("TERM %lld IS %lld/%lld\n",print_n,lob,hor);
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment