summaryrefslogtreecommitdiff
path: root/2010/qual/b/b.py
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2011-04-10 23:31:41 +0300
committerYuval Adam <yuv.adm@gmail.com>2011-04-10 23:31:41 +0300
commit8e1d5a67f66c5de7983aab6ed681f52ecf1c2242 (patch)
tree94e77fc19d5857a67455b94027c11e9f2186e5bb /2010/qual/b/b.py
parent72c7ce3bd2b28ae5e15020b25244891abc40f81a (diff)
solved fair warning
Diffstat (limited to '2010/qual/b/b.py')
-rw-r--r--2010/qual/b/b.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/2010/qual/b/b.py b/2010/qual/b/b.py
new file mode 100644
index 0000000..82bc96e
--- /dev/null
+++ b/2010/qual/b/b.py
@@ -0,0 +1,21 @@
+f = open('2.in', 'r')
+o = open('2.out', 'w')
+
+c = int(f.readline().strip())
+
+def gcd(a, b):
+ return a if b==0 else gcd(b, a % b)
+
+for i in range(c):
+ t = map(int, f.readline().strip().split(' ')[1:])
+ l = [abs(x - t[0]) for x in t]
+ g = reduce(gcd, l)
+
+ if t[0] % g == 0:
+ r = 0
+ else:
+ r = g - (t[0] % g)
+
+ s = "Case #%d: %s\n" % (i+1, r)
+
+ o.write(s)