UVA 10346 - Peter's Smokes

Problem PDF

Solution:

#include
int main()
{
int a,n,k;
while(scanf("%d %d",&n,&k)==2 && k>1)
{
a=n;
while(n>=k)
{
a=a+(n/k);
n=(n/k)+(n%k);
}
printf("%d\n",a);
}
return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/10346/10346.cpp