Cancel fractions by

g(a,b){return b?g(b,a%b):a;}main(n,d,G){for(;~scanf("%d/%d",&n,&d);printf((d/=G)-1?"%d/%d\n":"%d\n",n/=G=g(n,d),d));}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page