srtgguy

Untitled

May 23rd, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int time = 0, computers = 1, n, k, shnurs = 1;
  9.     cin >> n >> k;
  10.     if (k >= n)
  11.     {
  12.         while (pow(2, time) < n)
  13.         {
  14.             time += 1;
  15.         }
  16.         cout << time << endl;
  17.     }
  18.     if (k < n)
  19.     {
  20.         while (shnurs < k)
  21.         {
  22.             time += 1;
  23.             computers += shnurs;
  24.             shnurs += shnurs;
  25.         }
  26.         shnurs = k;
  27.         if ((n - computers) % k == 0)
  28.         {
  29.             time = time + (n - computers) / k;
  30.         }
  31.         else
  32.             time = time + (n - computers) / k + 1;
  33.         cout << time;
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment