18 lines
335 B
Python
18 lines
335 B
Python
def gcd(n,m) :
|
|
temp = [n,m]
|
|
n = max(temp)
|
|
m = min(temp)
|
|
if m==0 :
|
|
return n
|
|
return gcd(m,n%m)
|
|
|
|
def lcm(n,m) :
|
|
return n*m//gcd(n,m)
|
|
|
|
a,b = map(int,input().split())
|
|
c,d = map(int,input().split())
|
|
denom = lcm(b,d)
|
|
num = a*(denom//b) + c*(denom//d)
|
|
|
|
factor = gcd(num, denom)
|
|
print(num//factor, denom//factor) |