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函數(shù)的理解12 PRint('YES' if gcd == 1 else 'NO')
Link:
https://www.hackerrank.com/challenges/sherlock-and-gcd
學(xué)習(xí):
深度抽象問題
不斷地抽象問題的本質(zhì),層級(jí)越高,越簡(jiǎn)單!
reduce
循環(huán)apply fuc
gcd
greatest commen diviosr
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注