Next sparse binary number
Easy Accuracy: 46.42% Submissions: 2423 Points: 2

Given an integer n in the input, find its next sparse binary number.A sparse binary number is a number whose binary representation does not contain any consecutive 1s.

Input:
The first line of input contains an integer T denoting the number of test cases. The first line of each test case is number 'N'

Output:
Print next Sparse binary number,if the input number is not sparse else print the number itself.

Constraints:
1 ≤ T ≤ 100
1 ≤ n ≤ 100000

Example:
Input:
2
3
5

Output:
4
5

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.