yhl123456666 @ 2024-08-01 11:17:08
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,c,f;
cin>>n>>k;
while(n!=1){
n--;
c++;
f++;
if(f=k){
n++;
f==0;
}
}
cout<<c;
return 0;
}
by _chicken_ @ 2024-08-01 11:18:45
if中是f==k
by _chicken_ @ 2024-08-01 11:20:10
if里面是f=0
by _chicken_ @ 2024-08-01 11:21:09
@yhl123456666
by _chicken_ @ 2024-08-01 11:21:59
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,c,f;
cin>>n>>k;
while(n!=1){
n--;
c++;
f++;
if(f==k){
n++;
f=0;
}
}
cout<<c;
return 0;
}
by yhl123456666 @ 2024-08-01 11:24:29
谢谢,尬了?
by _chicken_ @ 2024-08-01 11:27:07
还有一个
by _chicken_ @ 2024-08-01 11:27:36
循环条件应该是n>0
by _chicken_ @ 2024-08-01 11:28:14
@yhl123456666
by yhl123456666 @ 2024-08-01 11:33:48
@_ckicken_多谢
by joe_001 @ 2024-08-06 19:20:44
@chicken 条件是n>k吧。