BC_114514 @ 2023-09-29 18:06:05
#include<bits/stdc++.h>
using namespace std;
int cnt;
int n, k;
int yd;
int main() {
cin >> n >> k;
while(n != 0) {
n--;
yd++;
if (yd == k) {
cnt++;
yd = 0;
}
}
cnt += n;
cout << cnt;
return 0;
}
大佬们,我哪里错啦~~
by hehedago_QAQ_ @ 2023-09-29 18:14:24
#include<bits/stdc++.h>
using namespace std;
int cnt=0,n, k;
int yd=0;
int main() {
cin >> n >> k;
int n1=n;
while(n1 != 0) {
n1--;
yd++;
if (yd == k) {
cnt++;
n1++;
yd = 0;
}
}
cnt += n;
cout << cnt;
return 0;
}
by hehedago_QAQ_ @ 2023-09-29 18:17:01
你最后n都减到0了……
用另一个变量保存
而且yd到达k之后烟的数量还要加一