about summary refs log tree commit diff
path: root/codechef/hp18.py
blob: 153ec190bb7fc8ecc32a2612d9a54323d786a9a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
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')