#20444: Python


howard20060216@gmail.com (Howard)


PYTHON 中的一個模組math.gcd()

 

#21391: Re:Python


10811124@stu.cmsh.khc.edu.tw (立峰陳)


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
好像不太行欸......



#21392: Re:Python


asnewchien@gmail.com (david)


import sys

from math import gcd

 

for s in sys.stdin:

    a, b = map(int, s.split())

    r = .....

    print(r)

 

這樣有沒有清爽一點。

#23835: Re:Python


911091@stu.cchs.chc.edu.tw (莊明達)


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;