From ce56bd193a7c8c6437443227cd3abb51134e3e7a Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 14 Jan 2019 20:41:09 +0700 Subject: At least I managed to stay in top 10% --- codechef/hp18.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 codechef/hp18.py (limited to 'codechef/hp18.py') 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') -- cgit 1.4.1