[Problem-solving report] 11689 - Soda Surpler

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:

Column 1 has an input integer N, representing the number of test cases.
A test data each, containing three integers e, f, c. e (0 <= e <1000 ) representative of the number of empty bottles Tim outset has, f (0 <= f < 1000) representative of the number of empty bottle Tim day he collected in the street, c (1 <c < 2000) the number of empty bottles on behalf of the new soda can for a bottle.
Please refer to SampleInput.

 

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.

View Code
#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

Guess you like

Origin blog.csdn.net/weixin_33924312/article/details/94237258
Recommended