import math
def lcm(a,b):
return (a * b) / math.gcd(a,b)
def solution(denum1, num1, denum2, num2):
denum3 = 0
denum4 = 0
denum5 = 0
denum6 = 0
answer = []
if math.gcd(num1, num2) == 1:
denum1 = denum1 num2
denum2 = denum2 num1
denum3 = denum1 + denum2
denum4 = round(lcm(num1, num2))
denum5 = round(denum3 / math.gcd(denum3, denum4))
denum6 = round(denum4 / math.gcd(denum3, denum4))
answer += [round(denum5), round(denum6)]
return answer
else:
denum1 = (lcm(num1, num2) / num1) denum1
denum2 = (lcm(num1, num2) / num2) denum2
denum3 = round(denum1 + denum2)
denum4 = round(lcm(num1, num2))
denum5 = denum3 / math.gcd(denum3, denum4)
denum6 = denum4 / math.gcd(denum3, denum4)
answer += [round(denum5), round(denum6)]
return answer