공부기록/백준

[백준] 14490번 백대열

메델 2024. 2. 4. 16:35
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		
		Scanner kb = new Scanner(System.in);
		String question = kb.next();
		
		String[] nums = question.split(":");
		BigInteger[] bigIntegerNums = new BigInteger[2];
		
		for(int i=0; i<2; i++) {
			bigIntegerNums[i] = new BigInteger(nums[i]);
		}
		
		BigInteger gcd = bigIntegerNums[0].gcd(bigIntegerNums[1]);
		
		StringBuilder sb = new StringBuilder();
		
		sb.append(bigIntegerNums[0].divide(gcd)).append(":").append(bigIntegerNums[1].divide(gcd));
		System.out.println(sb);


	}


}