백준 1934번 "최소공배수"

sanha_OvO·2021년 4월 12일
0

Algorithm

목록 보기
17/84

문제

백준 1934번 최소공배수


풀이

여기를 참조!


Python 코드

import sys
input = sys.stdin.readline

n = int(input())

def gcd(a, b):
  x, y = a, b
  while y > 0:
    x %= y
    x, y = y, x
  return x

for _ in range(n):
  a, b = map(int, input().split())
  num = gcd(a, b)
  print(a*b//num)
profile
Web Developer / Composer

0개의 댓글