practivceAlgorithm/백준
[백준][Python] 6064 카잉달력 : 최소공배수 컨트롤
findTheValue
2021. 7. 28. 23:53
결국 반복문으로 x나y를 증가시켜 일정 배수를 만드는게 목표이다. 변수가 나오면 항등식을 잘 세울 것.
==만 생각하는게 아니라 %로 일정 배수 만드는 경우도 유의할 것.
def num(m, n, x, y):
while x <= m * n:
if (x - y) % n == 0:
return x
x += m
return -1
t = int(input())
for i in range(t):
m, n, x, y = map(int, input().split())
print(num(m, n, x, y))