Cancel fractions by teebee

import java.util.*;enum C{C;System z;int a,n,d;{for(Scanner s=new Scanner(z.in).useDelimiter("/|\n");s==s;z.out.println(d>a?n/a+"/"+d/a:n/d))for(a=n=s.nextInt(),d=s.nextInt();n%a+d%a>0;a--);}}

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

download

return to the top page