摘要
Title: 872. 最大公约数
Tag: gcd
Memory Limit: 64 MB
Time Limit: 1000 ms
Powered by:NEFU AB-IN
Link
872. 最大公约数
-
题意
给定 n 对正整数 ai,bi,请你求出每对数的最大公约数。
-
思路
-
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| ''' Author: NEFU AB-IN Date: 2022-03-10 10:32:35 FilePath: \ACM\Acwing\872.py LastEditTime: 2022-03-10 10:32:35 '''
def gcd(a, b): return gcd(b, a % b) if b else a
for _ in range(int(input())): a, b = map(int, input().split()) print(gcd(a, b))
|