XOR Equation
InterviewTime limit2sMemory limit512 MB
Count ordered pairs of positive integers A and B with A+B=S and A xor B=X.
- Level
Medium6 of 10
- Topics
- Math, Bit manipulation
- Solved
- No attempts yet
Problem
You are given two positive integers and . Count the ordered pairs of positive integers that satisfy and , where is the bitwise exclusive or.
Both and must be at least . If , then and count as two different pairs.
Input
The first line contains two positive integers and , separated by a space. ()
Output
Print on the first line the number of ordered pairs that satisfy both equations.