Subject to the effect
Original title: http://uva.onlinejudge.org/external/116/11689.pdf
background:
Tim is a man very much in love of soft drinks. Since he had no money, so the only way he has to collect empty soda is soda bottles, then take it recovered in exchange for money and buy new soda drink. In addition to his own drinking empty bottles, Tim will go onto the streets collecting empty bottles of drinking of others. One day, he was very thirsty, he wants to soft drinks as much as possible, until he can not get up any bottle.
Input:
Output:
For each set of test data output one, on behalf of Tim how much you can drink soda bottle.
algorithm:
When this is relatively simple a question, question head and our teacher organizations like the ACM conduct selection, remember that time I did wrong, because too simple.
Code:
Here attached my code, you can go here to submit your code to verify your code is correct.
#include<stdio.h> int main(void) { int n,a,b,c,d,sum,flag; scanf("%d",&n); while(n--) { sum=0; scanf("%d %d %d",&b,&d,&c); a=b+d; while(a) { flag=a/c; sum+=a/c; a=flag+a%c; if(a<c-1)break; else if(a<=c-1)break; } printf("%d\n",sum); } return 0; }
Reproduced in: https: //www.cnblogs.com/qisong178878915/archive/2013/02/25/2932541.html