wwjtaimei @ 2023-08-04 09:38:47
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,cnt;
cin>>n>>k;
int yt;
while(n!=0){
n--;
yt++;
if(yt==k)
n++,
yt=0;
cnt++;
}
cout<<cnt;
return 0;
}
by sutianyi @ 2023-08-04 09:53:11
你应该将cnt初始化为0,就可以过了
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,cnt=0;
cin>>n>>k;
int yt;
while(n!=0){
n--;
yt++;
if(yt==k)
n++,
yt=0;
cnt++;
}
cout<<cnt;
return 0;
}