Sort by

recency

|

202 Discussions

|

  • + 0 comments

    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

    return simplify(nomerator, demirator)
    

    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)

  • + 0 comments
    from fractions import Fraction
    from functools import reduce
    def product(fracs):
        t = reduce(lambda x, y: x*y, fracs)
        return t.numerator, t.denominator
    if __name__ == '__main__':
        fracs = []
        for _ in range(int(input())):
            fracs.append(Fraction(*map(int, input().split())))
        result = product(fracs)
        print(*result)
    
  • + 0 comments
    from fractions import Fraction
    from functools import reduce
    from operator import mul
    
    def product(fracs):
        t = reduce(mul, fracs)
        return t.numerator, t.denominator
    
    if __name__ == '__main__':
        fracs = []
        for _ in range(int(input())):
            fracs.append(Fraction(*map(int, input().split())))
        result = product(fracs)
        print(*result)
    
  • + 0 comments
    from fractions import Fraction
    from functools import reduce
    
    def product(fracs):
        t = reduce(lambda x, y: x*y, fracs)  # complete this line with a reduce statement
        return t.numerator, t.denominator
    
    if __name__ == '__main__':
        fracs = []
        for _ in range(int(input())):
            fracs.append(Fraction(*map(int, input().split())))
        result = product(fracs)
        print(*result)
    
  • + 0 comments
    def product(fracs):
        t = reduce(lambda x, y : x * y, fracs)
        return t.numerator, t.denominator