728x90
반응형
https://www.acmicpc.net/problem/2436
문제 해결
최소 공배수를 최대 공약수로 나누었을 때의 수를 서로소인 두 인수로 쪼개서 확인하는 작업을 하면 끝
CODE
import sys
input = sys.stdin.readline
import math
def solve(res,a):
target = sys.maxsize
x, y = -1, -1
for i in range(1,int(math.sqrt(res)+1)):
if res%i:continue
j = res//i
if math.gcd(i,j) != 1: continue
if i*a + j*a < target:
x = i*a; y = j*a
print(x, y)
return
if __name__ == "__main__":
A, B = map(int, input().split())
diff = B//A
solve(diff,A)
728x90
반응형
'알고리즘 > [python] 백준 BOJ' 카테고리의 다른 글
[python] 백준 2643 색종이 올려 놓기 (0) | 2024.04.08 |
---|---|
[python] 백준 1507 궁금한 민호 (0) | 2024.04.06 |
[python] 백준 11562 백양로 브레이크 (1) | 2024.04.03 |
[python] 백준 5376 소수를 분수로 (0) | 2024.03.28 |
[python] 백준 2304 창고 다각형 (0) | 2024.03.14 |
댓글