Bitmanipulation hulknproblem

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a;
cin>>a;

        int b=a;
        while((a&(a-1))!=0)
        a--;
         b=b-a;
        cout<<b+1<<endl;
    

}

}

according to me it is rih=ght why it is showing wrong answers?

Your code will give wrong answer for a test case like N=36. The answer would be 2 but your code would give 5. Basically, N could be formed by a combination of powers of 2 as well.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.