k = int(input())
x1,y1=map(int,input().split())
x2,y2 =map(int,input().split())
x = 0
while k>0:
x = x +k
if x%x1==0:k = k - y1
if x%x2==0:k = k - y2
print(x)
data:
7
3 2
2 3
Output:
18
沒有留言:
張貼留言