rengetsu

Codeforces_579A

Jul 16th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. //Codeforces 579A
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int x, q, res = 0, res_sk = 0;
  10.     bool test1 = true, test2 = true;
  11.     cin >> x;
  12.     while( test1 == true)
  13.     {
  14.         q = 1;
  15.         while( test2 == true )
  16.         {
  17.             if(((q*2)+res_sk) <= x)
  18.             {
  19.                 q = q*2;
  20.             }
  21.             else{ test2 = false; res++; res_sk+=q;}
  22.         }
  23.         if(res_sk >= x){test1 = false;}
  24.         else{test2=true;}
  25.     }
  26.     cout << res;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment