Hackerrank solutions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
511 B

#!/usr/bin/python3
# https://www.hackerrank.com/challenges/sherlock-and-gcd
import sys
from fractions import gcd
def gcd_all(numbers):
res = 0
for n in numbers:
res = gcd(res, n)
return res
def main():
T = int(sys.stdin.readline())
for _ in range(T):
N = int(sys.stdin.readline())
A = [ int(x) for x in sys.stdin.readline().split() ]
if gcd_all(A) == 1:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()