Advertisement
Hamoudi30

Problem C

May 14th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 200009;
  4. int main() {
  5.     ios_base::sync_with_stdio(false);
  6.     cin.tie(nullptr);
  7.     cout.tie(nullptr);
  8. //    freopen("/home/hamoudi/Coding/run.in", "r", stdin);
  9.     int tt = 1;
  10.     cin >> tt;
  11.     while (tt--) {
  12.         int computers, cables;
  13.         cin >> computers >> cables;
  14.         int counter = 0;
  15. //      first we will start with only 1 cable and connect it to only one conputer
  16.         int used_cables = 1;
  17.         while (computers > 0) {
  18. //            then we will decrease number of remaining computers by connect it to the min between cables and used_cables
  19.             computers -= min(used_cables, cables);
  20. //             now we can increment the number used_cables
  21.             used_cables += min(cables, used_cables);
  22. //            we have done an operation, so we have to increment the counter
  23.             ++counter;
  24.         }
  25.         cout << counter << '\n';
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement