
- 유클리드 호제법을 이용하여 구했다
num1, num2 = map(int, input().split())
# 유클리드 호제법을 사용하여 최대공약수를 구함
def gcd(a, b):
remainder = a % b
while remainder > 0:
# a와 b의 값을 갱신
a = b
b = remainder
remainder = a % b
return b
print('1' * gcd(num1, num2))'Python > 백준' 카테고리의 다른 글
| [백준/Python] 1339. 단어 수학 (0) | 2023.10.12 |
|---|---|
| [백준/Python] 4179. 불! (0) | 2023.08.04 |
| [백준/Python] 13241.최소공배수 (0) | 2023.04.12 |
| [백준/Python] 12761.돌다리 (0) | 2023.03.03 |
| [백준/Python] 13565. 침투 (0) | 2023.03.02 |

