Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define B(x) (1<<x)
- #define ll long long
- int main() {
- int t;
- cin>>t;
- while(t--) {
- int n;
- cin>>n;
- int p, temp=0;
- for(p=0; ; p++) if(n < B(p)) break;
- p--;
- for( int i=B(0), j=0; i<=B(p); i=i+B(++j) ) temp += B(j) -1;
- temp += n - B(p);
- cout<<temp<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement