Advertisement
kadeyrov

Untitled

Oct 4th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  AndeyLess
  4. //
  5. //  Created by Kadir Kadyrov on 08.07.2020.
  6. //  Copyright © 2020 Kadir Kadyrov. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11. #include <queue>
  12. #include <algorithm>
  13.  
  14. using namespace std;
  15.  
  16. int main() {
  17.     int a, b;
  18.     cin >> a >> b;
  19.     int curr = a, ans = 0, currB = 0;
  20.    
  21.     while(curr > 0) {
  22.         ans += curr;
  23.         currB += curr;
  24.         curr = currB / b;
  25.         currB %= b;
  26.     }
  27.    
  28.     cout << ans << endl;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement