#46328: Python解


chunyutsai97@gmail.com (淳)

學校 : 臺北市立陽明高級中學
編號 : 259744
來源 : [122.116.19.249]
最後登入時間 :
2025-10-05 17:06:03

k = int(input())
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

i = 0
while k > 0:
    i += k
    if i % x1 == 0:
        k -= y1
    if i % x2 == 0:
        k -= y2

print(i)