Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 200009;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // freopen("/home/hamoudi/Coding/run.in", "r", stdin);
- int tt = 1;
- cin >> tt;
- while (tt--) {
- int computers, cables;
- cin >> computers >> cables;
- int counter = 0;
- // first we will start with only 1 cable and connect it to only one conputer
- int used_cables = 1;
- while (computers > 0) {
- // then we will decrease number of remaining computers by connect it to the min between cables and used_cables
- computers -= min(used_cables, cables);
- // now we can increment the number used_cables
- used_cables += min(cables, used_cables);
- // we have done an operation, so we have to increment the counter
- ++counter;
- }
- cout << counter << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement