#include #include #define N 2010 #define K 510 char mol[K][N],den[K][N]; char virt[N]; int gcd(int a,int b) { return b?gcd(b,a%b):a; } int divide(char *str,int n,char *s) { int i,k,len; len=strlen(str); s[len]=0; for(k=0,i=len-1;i>=0;i--) { k=k*10+str[i]-'0'; s[i]=k/n+'0'; k%=n; } for(i=len-1;i>0;i--) { if(s[i]!='0') break; s[i]=0; } return k; } void mult(char *str,int n,char *x) { int i,s[N]; for(i=0;i0 && s[i]==0;i--); x[i+1]=0; for(;i>=0;i--)x[i]=s[i]+'0'; } void init() { int i,j,k; strcpy(mol[1],"1"); strcpy(den[1],"2"); for(i=2;i1) divide(den[i],k,den[i]); mult(mol[i],j/k,mol[i]); strrev(mol[i-1]); strrev(den[i-1]); } } int main() { int n,T; init(); scanf("%d",&T); while(T--) { scanf("%d",&n); printf("%s/%s\n",mol[n],den[n]); } return 0; }