#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main() { int n,m,i,k; while(~scanf("%d",&n)) { m=n; int t=1; for(i=1;i<10000000;i++) { m=m-i; if(m<=i+1) { //printf("i=%d\n",i); t=i+1; break; } } int x=1,y=1; if(n==1) printf("TERM %d IS 1/1\n",n); else { if(t%2==0) { x=t; y=1; for(i=1;i<=t;i++) { if(i==m) printf("TERM %d IS %d/%d\n",n,y,x); x--; y++; } } else { x=1; y=t; for(i=1;i<=t;i++) { if(i==m) printf("TERM %d IS %d/%d\n",n,y,x); x++; y--; } } // printf("%d m=%d\n",t,m); } } return 0; } |
Double click to view unformatted code.