#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; for (int i=0;i<N;i++){ int e,f,c; cin>>e>>f>>c; int total=e+f; // 總空瓶數 int empty=0; // 喝到的汽水瓶數 // 只要還能換到汽水,就持續循環 while (total>=c){ int new_bottles=total/c; // 可以得到的新汽水瓶數 empty+=new_bottles; // 累加喝到的汽水瓶數 total=total-(new_bottles*c)+new_bottles; // 更新空瓶數 } cout<<empty<<endl; } return 0; }