BOJ - 1735 - 분수 합

Updated:

def GCD(x, y):
    mod = x % y
    while mod > 0:
        x = y
        y = mod
        mod = x % y
    return y

def solution():
    A, B = map(int, input().split())
    C, D = map(int, input().split())

    N = GCD(A * D + C * B, B * D)

    print((A * D + C * B) // N, B * D // N)

solution()

https://www.acmicpc.net/problem/1735

Categories:

Updated:

Leave a comment