Gray to Binary equivalent
Basic Accuracy: 55.99% Submissions: 1930 Points: 1

Given N in Gray code equivalent. Find its binary equivalent.

Input:
The first line contains an integer T, number of test cases. For each test cases, there is an integer N denoting the number in gray equivalent.

Output:
For each test case, in a new line, the output is the decimal equivalent number N of binary form.

Constraints:
1 <= T <= 100
0 <= n <= 108

Example:
Input

2
4
15
Output
7
10

Explanation:
Testcase1. 
4 is represented as 100 and its binary equivalent is 111 whose decimal equivalent is 7.
Testcase2. 15 is represented as 1111 and its binary equivalent is 1010 i.e. 10 in decimal.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.