// UVa 10346 - Peter's Smokes #include <iostream> using namespace std; int main() { int n, k; while (cin >> n >> k) { int left = n; int butts = 0; int smoked = 0; while (left) { smoked += left; butts += left; left = butts / k; butts = butts % k; } cout << smoked << endl; } return 0; }
No comments:
Post a Comment