Advertisement
Imran2544

[UVa 10346] Peter's Smoke

Nov 4th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, k;
  7.     while (cin>>n>>k) {
  8.         int b=0, s=0;
  9.         while (n>0) {
  10.             s+=n;
  11.             b+=n;
  12.             n=b/k;
  13.             b=b%k;
  14.         }
  15.         cout<<s<<endl;
  16.     }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement