Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. import math
  2. import itertools
  3.  
  4. num_of_tests = int(input())
  5. tests = []
  6. for test in range(0, num_of_tests):
  7. tests.append(list(map(int, input().split()))[1:])
  8. for test in tests:
  9. gcd_sum = 0
  10. for pair in itertools.combinations(test, 2):
  11. gcd_sum += math.gcd(pair[0], pair[1])
  12. print(gcd_sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement