Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, k, x, y = map(int, input().split())
- num = n // k * x + (n - n // k) * y
- q = int(input())
- quer = list(map(int, input().split()))
- for i in range(q):
- quer[i] -= 1
- def ans(a):
- kv = a % num
- in_block = (k - 1) * y + x
- num_block = kv // in_block
- num_in_block = kv % in_block
- if num_in_block >= (k - 1) * y:
- floor_in_block = k
- else:
- floor_in_block = num_in_block // y + 1
- return num_block * k + floor_in_block
- for i in quer:
- print(ans(i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement