• + 0 comments

    i don't know about C++ but buddy in C, if you are using unsigned long long type variable while doing operations with constants explicitly mention the type (though automatic type conversion happens but to be on safe side) do use proper SUFFIX representing the type of constant you are using.

    for ex , x = n & 1 ----> x = n & 1ULL (because n is unsigned long long)

    (x == 0) ---> (x == 0ULL)

    and finally i compiled your code this power function is creating an issue,

    remember whenever power of 2 is to be calculated it can be done by simply left shifting 1 to those number of bits

    therefore next time instead of using (2,exponent) ---- > (1ULL << exponent)

    int main(){
        unsigned long long int n,count=0,x;
        cin>>n;
        while(n)
        {
            x=n&1ULL;
            if(x==0ULL)
             count++;   
            n>>=1;
        }
        cout<<(1ULL << count);
        return 0;
    }