Sherlock and GCD

时间:2022-07-04 11:04:11
 1 import fractions, functools, sys

 if __name__ == '__main__':
T = int(sys.stdin.readline()) for _ in range(T):
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split())) gcd = functools.reduce(fractions.gcd, A) # reduce函数的理解
print('YES' if gcd == 1 else 'NO') Link:
  https://www.hackerrank.com/challenges/sherlock-and-gcd 学习:
  深度抽象问题
    不断地抽象问题的本质,层级越高,越简单!
  reduce
    循环apply fuc
  gcd
    greatest commen diviosr