Cancel fractions by schpey

p,q;main(i){for(;~scanf("%d/%d",&p,&q);printf(q-1?"%d/%d\n":"%d\n",p,q))for(i=2;i<=p;)p%i|q%i?i++:(p/=i,q/=i);}

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

download

return to the top page