照題目算出答案即可。
P.S. 注意換完的瓶子又可再變成空瓶子拿去換。
C++(0.008)
/*******************************************************/
/* UVa 11689 Soda Surpler */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/10/17 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int N;
int e, f, c;
int all, change;
while( scanf( "%d", &N ) != EOF ){
for( int i = 0 ; i < N ; i++ ){
scanf( "%d%d%d", &e, &f, &c );
all = e+f;
change = 0;
while( all/c ){
change += all/c;
all = all/c + all%c;
}
printf( "%d\n", change );
}
}
return 0;
}