Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Codeforces 579A
- #include <iostream>
- using namespace std;
- int main()
- {
- int x, q, res = 0, res_sk = 0;
- bool test1 = true, test2 = true;
- cin >> x;
- while( test1 == true)
- {
- q = 1;
- while( test2 == true )
- {
- if(((q*2)+res_sk) <= x)
- {
- q = q*2;
- }
- else{ test2 = false; res++; res_sk+=q;}
- }
- if(res_sk >= x){test1 = false;}
- else{test2=true;}
- }
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment