Friday, November 8, 2013

UVA10346 - Peter's Smokes



10346 - Peter's Smokes



Solution:


#include < stdio.h >

int main()
{
    int n,k,b,a;
    while(scanf("%d %d",&n,&k)==2)
    {
        b=n;
        while(n>=k)
        {
            b=b+n/k;
            n=(n/k)+(n%k);
        }
        printf("%d\n",b);
    }
}


Problem & Solution Download

No comments:

Post a Comment