Xor is Mad

QUESTION

The problem is straight and simple.\nGiven a number X ,find how many positive A ( A>0) exists, such that \n\n1 . A OR X =A + X \n2. A<X\n\nInput:\n\nThe first line of the input will contain T , the number of test-cases. \n\nNext T lines will contain integer X . \n\nOutput:\n\nFor each test-case , output the answer in a separate line.\n\nConstraints:\n\n1<=T<=10^5\n1<=X<=10^7\n\nNote: \nOR is the bitwise Exclusive-OR operator( XOR ). and + is the usual addition symbol\n.

ANSWER


             #include<stdio.h>
    int main()
    {long t,n,count;
    scanf("%ld",&t);
    while(t--)
    {count=1;
    scanf("%ld",&n);
    while(n)
    {if(n%2==0)
    count*=2;
    n=n/2;
    }
    printf("%ld\n",count-1);
    }
    }
 
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock