Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import itertools
- num_of_tests = int(input())
- tests = []
- for test in range(0, num_of_tests):
- tests.append(list(map(int, input().split()))[1:])
- for test in tests:
- gcd_sum = 0
- for pair in itertools.combinations(test, 2):
- gcd_sum += math.gcd(pair[0], pair[1])
- print(gcd_sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement