1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include <iostream> #include <cstdio> #define ul unsigned long long #define INT_MX 2147483641 using namespace std; ul binsearch(ul n,ul lw,ul hi) { ul mid; ul tmp,tmp1,tmp2; while(lw<hi) { mid=(lw+hi)/2; tmp = (mid*(mid+1))/2; if(tmp<=n) lw=mid+1; else if(tmp>n) hi=mid; } return hi; } int main() { ul n; ul diff,hi,lw; ul neumenator,denominator; while(cin>>n) { hi = binsearch(n,0,INT_MX); diff = n-(hi*(hi-1))/2; if(diff==0) { printf("%llu/%llu\n",1,hi-1); } else { printf("%llu/%llu\n",hi-(diff-1),diff); } } return 0; } |