Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Gcd(a, b):
- if b == 0:
- return a
- return Gcd(b, a % b)
- def Solve(L):
- y = L[0]
- L1 = [abs(x - y) for x in L]
- g = reduce(Gcd, L1)
- if y % g == 0:
- return 0
- else:
- return g - (y % g)
- with open('B-large-practice.in') as f:
- lines = f.readlines()
- with open('B-large-practice.out', 'w') as output:
- N = int(lines[0])
- for testcase, i in enumerate(range(N)):
- codes = map(int,lines[i+1].split())
- output.write("Case #%d: %d\n" % (testcase+1, Solve(codes[1:])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement