Superdromes

1

1 votes
Open, Approved, Open, Approved, Open, Basic Programming, Easy, Implementation, Basics of Implementation
Problem

You have recently read about superdromes. Superdromes are those numbers that are palindromic in both binary and decimal representation.

The number represented in binary representation is up to its most significant bit that is 1. For example, 2 will be represented as {10}, 6 is represented as {110}, and so on.

Your task is to determine the number of superdromes that are less than or equal to n for provided n.

Input format

  • First line: A single integer q denoting the number of queries
  • Next line: q space-separated integer where the ith integer is n for the ith query

Output format
Print a single integer that represents the number of superdromes that is less than or equal to n for each query. Print the answer for each query as space-separated integers.

Constraints

1q105

1n106

Sample Input
3
1 2 3 
Sample Output
1 1 2 
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

1 and 3 are superdromes while 2 is not a superdrome.

Contributers:
Editor Image

?