You are viewing a single comment's thread. Return to all comments →
Not a big change but you can iterate less times:
import sys from functools import reduce from fractions import gcd input() a = map(int,input().strip().split()) b = map(int,input().strip().split()) lcm_a = reduce(lambda x,y: x*y//gcd(x,y), a) gcd_b = reduce(gcd, b) gcd_b_copy = gcd_b print(sum(1 for x in range(lcm_a,gcd_b+gcd_b_copy,lcm_a) if gcd_b%x==0))
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Not a big change but you can iterate less times: