# Sum vs XOR

**Problem Statement**

Given an integer, , find each such that:

where denotes the bitwise XOR operator. Then print an integer denoting the total number of ‘s satisfying the criteria above.

**Input Format**

A single integer, .

**Constraints**

**Output Format**

Print the total number of integer ‘s satisfying both of the conditions specified above.

**Sample Input**

1 |
5 |

**Sample Output**

1 |
2 |

**Explanation**

For , the values and satisfy the conditions:

Thus, we print as our answer.

**Solution**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public class SumVsXor { public static void main(String[] args) throws FileNotFoundException { System.setIn(new FileInputStream(System.getProperty("user.home") + "/" + "in.txt")); Scanner in = new Scanner(System.in); long n = in.nextLong(); int zeros = 0; while (n > 0) { if ((n & 1) == 0) { zeros++; } n = n >> 1; } long ans = 1l << zeros; System.out.println(ans); } } |