Set Definition
Time limit2sMemory limit512 MB
Find the N-th smallest number in the set generated from 1 by repeatedly applying x -> 2x+1 and x -> 3x+1.
- Level
Medium6 of 10
- Topics
- Heap, Math, Implementation
- Solved
- No attempts yet
Problem
The set is defined by the following rules.
- is an element of .
- If is an element of , then and are also elements of .
- A number that these two rules do not produce is not an element of .
is a set, so a value reachable in more than one way still counts as a single element.
List the elements of in increasing order and find the -th value.
Input
The first line contains the number of test cases (). Each of the next lines contains one integer ().
Output
For each test case, print the -th smallest element of on its own line.