2025年1月7日 星期二

紅綠灯

 a,b = map(int,input().split())

n = int(input())

ts =[ int(i) for i in  input().split()]

sw = 0

for t in ts:

  r = t % (a+b)

  if r < a:

    w = 0

  elif r == a:

    w = b

  else:

    w = b - (r-a)

    

  sw = sw + w

print(sw)


data:

10 10

1

14

Output:

6

沒有留言:

張貼留言