PYTHON 中的一個模組math.gcd()
import math
a=input()while a:try:b=a.split(' ')b=[int(i) for i in b]print(math.gcd(b[0],b[1]))a=input()except:break好像不太行欸......
縮行記得縮好!
import math
a=input()
while a:
try:
b=a.split(' ')
b=[int(i) for i in b]
print(math.gcd(b[0],b[1]))
a=input()
except:
break;
還有其實可以更短
import math
while 1:
try:
x, y = [int(i) for i in input().split()]
print(math.gcd(x, y))
except:
break;