https://zerojudge.tw/ShowProblem?problemid=a536
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=2736
X
留意空瓶子為「兌換後喝完的空瓶 + 沒有被兌換的空瓶」
n = int(input())
for _ in range(n):
e, f, c = map(int, input().split())
total = 0 # 可以喝幾瓶
bottles = e + f # 當前空瓶子數量
while bottles >= c:
total += bottles // c
bottles = bottles // c + bottles % c # 兌換後喝完的空瓶 + 沒有被兌換的空瓶
print(total)