Advertisement
Shiyan12

Untitled

Apr 3rd, 2021
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. from math import gcd
  2.  
  3. def get():
  4.     a = list(map(int, input().split()))
  5.     return [gcd(a[0], a[1]), gcd(a[0], a[2]), gcd(a[1], a[2])]
  6.  
  7. N = int(input())
  8. s = get()
  9. for i in range(N-1):
  10.     pair = get()
  11.     s1 = [0]*10
  12.     cmb = [a+b for a in s for b in pair]
  13.     for x in cmb:
  14.         r = x%10
  15.         s1[r] = max(s1[r], x)
  16.     s = [x for x in s1 if x != 0]
  17. s = [x for x in s if x%10 == 0]
  18. print(max(s))
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement