Created
January 27, 2015 14:34
-
-
Save anonymous/970a6479a08137e8a8fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
# pylint: disable=C0111 | |
from sys import stdin | |
def main(): | |
def gcd(a, b): | |
while b: | |
a, b = b, a % b | |
return a | |
def can_you(marks, n, m): | |
msig = sum(marks) | |
if n < m: | |
return 'NO' | |
if msig == 0: | |
return 'YES' | |
if 0 in marks: | |
return 'NO' | |
return 'NO' if any( | |
[gcd(msig, m_i * n) != msig for m_i in marks]) else 'YES' | |
inp = stdin.readlines() | |
for _ in xrange(int(inp[0])): | |
print can_you( | |
map(int, inp[2*_ + 2].split()), | |
*map(int, inp[2*_ + 1].split())) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment