Files
exercises/cs101/dh_20260909_12_bottle_exchange.cpp
T
2026-09-25 20:20:01 +08:00

23 lines
595 B
C++

#include <iostream>
using namespace std;
long long exchange_requirement, empty_bottles_amount, filled_bottles_amount, ans;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> exchange_requirement >> filled_bottles_amount;
while (true) {
ans += filled_bottles_amount;
empty_bottles_amount += filled_bottles_amount;
filled_bottles_amount = empty_bottles_amount / exchange_requirement;
empty_bottles_amount %= exchange_requirement;
if (filled_bottles_amount == 0) { break; }
}
cout << ans << endl;
return 0;
}