BTWR - Editorial

[Practice ] Bitwiser | CodeChef
Setter: rounak_rocco
Tester: virtual_worm
Editorialist: codechef_ciem

DIFFICULTY:

EASY

PREREQUISITES:

None

PROBLEM:

Find two non-negative integers h and g,over a given integer u, which satisfied this equation (h∧g)+(h∨g)=u, where ∧ is the bitwise AND operation and ∨ is the bitwise OR operation.

QUICK EXPLANATION:

One simple solution which satisfy this equation is h = 0and g = u, so (h∧g) = 0and (h∨g) = u, hence satisfing the equation.

TIME COMPLEXITY:

O(1) for each testcase.

SOLUTION(PYTHON)

t=int(input())
for i in range(t):
u=int(input())
print(0,u)