1
import fractions, functools, sys 2 3 4 if __name__ == '__main__': 5 T = int(sys.stdin.readline()) 6 7 for _ in range(T): 8 N = int(sys.stdin.readline()) 9 A = list(map(int, sys.stdin.readline().split())) 10 11 gcd = functools.reduce(fractions.gcd, A) # reduce函数的理解 12 print('YES' if gcd == 1 else 'NO')


Link:
  https://www.hackerrank.com/challenges/sherlock-and-gcd

学习:
  深度抽象问题
    不断地抽象问题的本质,层级越高,越简单!
  reduce
    循环apply fuc
  gcd
    greatest commen diviosr

 posted on 2015-05-14 10:56  sangocare  阅读(178)  评论(0编辑  收藏  举报