Sunday, April 24, 2016

UVA 11877 : The Coco-Cola Store -Solution

Unknown
#include <stdio.h>
int main()
{
    int t=10,n,b;
    while (scanf("%d",&n)==1&&t--)
    {
        if (n==0) break;
        b=0;
        while (n>1)
        {
            if (n==2)
            {
                b++;
                break;
            }
            else
            {
                b=b+n/3;
                n=n/3+n%3;
            }
        }
        printf("%d\n",b);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,