import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder("");
String m="";
int cases =Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++){
String[] str=br.readLine().split(" / ");
BigInteger bg1=new BigInteger(str[0]);
BigInteger bg2=new BigInteger(str[1]);
BigInteger gcd=bg1.gcd(bg2);
sb.append(bg1.divide(gcd)).append(" / ").append(bg2.divide(gcd)).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment