We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Reduce Function
Reduce Function
Sort by
recency
|
202 Discussions
|
Please Login in order to post a comment
from math import gcd
def simplify(nomerator, demirator): common_diviser = gcd(nomerator, demirator) return nomerator // common_diviser, demirator // common_diviser
def product_of_relations(relations): nomerator = 1 demirator = 1 for num, den in relations: nomerator *= num demirator *= den
n = int(input()) relations = [tuple(map(int, input().split())) for _ in range(n)] result_nomerator, result_denominator = product_of_relations(relations) print(result_nomerator, result_denominator)