FengYuXinMing @ 2022-09-04 10:30:39
#include <iostream>
using namespace std;
int main()
{
int n,k,k1 = 0,a = 0,sum = 0;//k1用来处存烟蒂,sum共吸了多少 ,a不定
cin >> n >> k;
k1 += n;
sum += n;
while (k1 > k){
a = n % k;
n += a;
sum += a;
k1 += a;
k1 %= k;
a = 0;
}
cout << sum;
return 0;
}
by williamwei @ 2022-09-04 11:03:57
详见空瓶换汽水。
by williamwei @ 2022-09-04 11:04:22
我待会上机把答案发你
by BlueTiger @ 2022-10-11 21:51:20
#include<iostream>
using namespace std;
int main(){
int a,b,tot=0,l=0;
cin>>a>>b;
while(l>=b){
l-=b;
a++;
}
while(a>0){
a--;
tot++;
l++;
if(l>=b){
l-=b;
a++;
}
}
cout<<tot<<endl;
return 0;
}