알고리즘 문제풀이
분수 합 [백준 1735]
wiojfe
2024. 7. 9. 13:17
https://www.acmicpc.net/problem/1735
a,b =map(int,input().split())
c,d =map(int,input().split())
up = (a*d) +(b*c)
down = b*d
def gcd(a,b):
while b :
a,b = b,a%b
return a
gcdnum = gcd(up,down)
up /=gcdnum
down/=gcdnum
print(int(up),int(down))