1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <iostream> #include <cstdio> using namespace std; int main() { int t; int e,f,c; int total_consumed,total_empty; scanf("%d",&t); while(t--) { scanf("%d%d%d",&e,&f,&c); total_consumed=0; total_empty=e+f; while(total_empty>=c) { total_consumed += (total_empty/c); total_empty = total_empty/c + total_empty%c; } cout<<total_consumed<<"\n"; } return 0; } |