题目地址:​​点击打开链接​

思路:水题

AC代码:

#include <iostream>
#include<cstdio>

using namespace std;

int main()
{
int m,k;
int sum,sum1,l;
while(scanf("%d%d",&m,&k))
{
if(m + k == 0)
break;
l = m;
sum1 = 0;
while(m>=k)
{
sum = m / k;
l += sum;
sum1 = m % k;
m = sum + sum1;
}
printf("%d\n",l);
}
return 0;
}