wjm2012 @ 2024-09-30 22:10:14
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,ans=0,b=1;
cin>>n>>k;
ans+=n;
for(int i=1;i<=n;i++){
b++;
if(b>=k){
ans+=1;
b-=k;
b++;
}
}
cout<<ans-1;
return 0;
}
我只过了3个测试点,有没有大佬帮帮我,回帖必关
by Gzh320667 @ 2024-09-30 22:14:58
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,ans=0,b=0;
cin>>n>>k;
ans+=n;
for(int i=1;i<=n;i++){
b++;
if(b>=k){
ans+=1;
b-=k;
b++;
}
}
cout<<ans;
return 0;
}
by wjm2012 @ 2024-09-30 22:15:43
谢谢
by zyx13765814016 @ 2024-10-02 15:28:51
挺简单的啊,就把b=1改成b=0嘛