Wednesday, April 13, 2016

UVA Problem 10346: Peter's Smokes-Solution

Unknown
#include<stdio.h>
int main()
{
    int n,k,s,b,tb,r;
    while(scanf("%d%d",&n,&k)==2)
    {
        s=n;
        tb=0;
        while(s>=k)
        {
            b=s/k;
            r=s%k;
            s=b+r;
            tb=tb+b;
        }
        printf("%d\n",n+tb);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,