BOJ 5347 LCM
2802 단어 2021.02.052021.02.05
https://www.acmicpc.net/problem/5347
시간 1초, 메모리 128MB
input :
- n
- a b
output :
- 두 수의 최소공배수를 출력
아까랑 동일하게
temp 에 두 수의 최대 공약수 저장.
a // temp 값, b // temp 값을 최대공약수에 곱하자.
import sys
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
t = int(sys.stdin.readline())
for i in range(t):
a, b = map(int, sys.stdin.readline().split())
temp = gcd(a, b)
print(temp * a // temp * b // temp)
Author And Source
이 문제에 관하여(BOJ 5347 LCM), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jsin2475/BOJ-5347-LCM저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)