Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import gcd
- def get():
- a = list(map(int, input().split()))
- return [gcd(a[0], a[1]), gcd(a[0], a[2]), gcd(a[1], a[2])]
- N = int(input())
- s = get()
- for i in range(N-1):
- pair = get()
- s1 = [0]*10
- cmb = [a+b for a in s for b in pair]
- for x in cmb:
- r = x%10
- s1[r] = max(s1[r], x)
- s = [x for x in s1 if x != 0]
- s = [x for x in s if x%10 == 0]
- print(max(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement