about summary refs log tree commit diff
path: root/codechef/hp18.py
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/hp18.py')
-rwxr-xr-xcodechef/hp18.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/codechef/hp18.py b/codechef/hp18.py
new file mode 100755
index 0000000..153ec19
--- /dev/null
+++ b/codechef/hp18.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+from functools import reduce
+from math import gcd
+
+for t in range(int(input())):
+    N, a, b = map(int, input().split())
+    lcm = a * b // gcd(a, b)
+    rm = map(lambda x: (x%a==0, x%lcm==0, x%b==0), map(int, input().split()))
+    Bob, both, Alice = reduce(lambda x, y: map(int.__add__, x, y), rm)
+    print('BOB' if Bob + bool(both) > Alice else 'ALICE')