Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define ALL(x) x.begin(),x.end()
- #define SZ(x) x.size()
- #define PB push_back
- #define MP make_pair
- #define F first
- #define S second
- typedef long long LL;
- typedef vector<int> VI;
- typedef pair<int,int> PI;
- int t,n;
- void solve() {
- cin >> n;
- bitset<32> a = n;
- bitset<32> b = n-1;
- string s1 = a.to_string();
- string s2 = b.to_string();
- int ans = 0;
- for(int i = 0; i < 32; i++)
- if(s1[i] != s2[i]) ans++;
- cout << ans << "\n";
- }
- int main() {
- io
- cin >> t;
- while(t--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement