Xor is Mad

3.8

21 votes
Bit manipulation, Basic Programming, Approved, Easy, Bit manipulation
Problem

The problem is straight and simple.
Given a number X ,find how many positive A ( A>0) exists, such that
1. A X =A + X
2. A < X
Input:
The first line of the input will contain T , the number of test-cases.
Next T lines will contain integer X .
Output:
For each test-case , output the answer in a separate line.

Constraints:

  • 1T105
  • 1X107
Note: is the bitwise Exclusive-OR operator( XOR ). and + is the usual addition symbol.

Sample Input
4
1
2
3
4
Sample Output
0
1
0
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Explanation for 1st test case:
For 1 there is no such number.
For 2nd case:
For 2 we have only one such number 1 2 = 3
For 3rd case:
For number 3 we have no such number .
For 4th case:
For number 4 we have 3 4 = 7 , 2 4 = 6 and 1 4 = 5. Hence the answer is 3.

Contributers:
Editor Image

?