반응형
https://www.acmicpc.net/problem/1934
1934번: 최소공배수
두 자연수 A와 B에 대해서, A의 배수이면서 B의 배수인 자연수를 A와 B의 공배수라고 한다. 이런 공배수 중에서 가장 작은 수를 최소공배수라고 한다. 예를 들어, 6과 15의 공배수는 30, 60, 90등이 있�
www.acmicpc.net
# @Author YoungMinKim
# baekjoon
def gcd(a,b):
if a<b:
a,b=b,a
while b!=0:
a,b= b,a%b
return a
def lcm(a,b):
return a*b // gcd(a,b)
N=int(input())
for i in range(N):
a,b = map(int,input().split())
print(lcm(a,b))
반응형
'백준 문제풀이' 카테고리의 다른 글
baekjoon - python - 2163 (0) | 2020.08.24 |
---|---|
baekjoon - python - 1977 (0) | 2020.08.24 |
baekjoon - python - 1924 (0) | 2020.08.21 |
baekjoon - python - 1712 (0) | 2020.08.21 |
baekjoon - python - 1550 (0) | 2020.08.21 |
댓글