Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int time = 0, computers = 1, n, k, shnurs = 1;
- cin >> n >> k;
- if (k >= n)
- {
- while (pow(2, time) < n)
- {
- time += 1;
- }
- cout << time << endl;
- }
- if (k < n)
- {
- while (shnurs < k)
- {
- time += 1;
- computers += shnurs;
- shnurs += shnurs;
- }
- shnurs = k;
- if ((n - computers) % k == 0)
- {
- time = time + (n - computers) / k;
- }
- else
- time = time + (n - computers) / k + 1;
- cout << time;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment