```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,ans=0;
cin>>n>>k;
while(n>0)
{
n--;
ans++;
if(ans%k==0)
n++;
}
cout<<ans;
return 0;
}
```
by yegengghost @ 2023-11-30 21:25:53
这道题建议用数学方法做:
```cpp
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
cin>>n>>k;
cout<<n+(n-1)/(k-1);
return 0;
}
```
输出n+(n-1)/(k-1)即可
by KraotsDom @ 2023-11-30 21:40:55
@[KraotsDom](/user/841550) 怎么发代码啊
by fangmiaoxin @ 2023-12-08 21:08:49
@[fangmiaoxin](/user/1141719) 点击编辑回复下面那一行东西的第15个键“</>”,把代码复制上去即可
by KraotsDom @ 2023-12-11 12:36:45
@[KraotsDom](/user/841550) 牛波一
by fangmiaoxin @ 2023-12-11 21:07:40