Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2015 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/970a6479a08137e8a8fd to your computer and use it in GitHub Desktop.
Save anonymous/970a6479a08137e8a8fd to your computer and use it in GitHub Desktop.
#!/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