#include<stdio.h> #include<stdlib.h> #define swap(a,b){int t; t=a; a=b; b=t;} int main(){ int n ; int i ; while(scanf("%d",&n)==1){ for(i=1 ; i<4473 ; ++i){ int low = (i*i-i+2)>>1 ; int high = ((i+1)*(i+1)-(i+1)+2)>>1 ; if(n>=low && n<high){ int left=1, right=i ; int d=n-low ; left += d, right -= d; if(i%2) swap(left,right) ; printf("TERM %d IS %d/%d\n", n, left, right) ; } } } return 0 ; }
沒有留言:
張貼留言