n, 3n, 5n
Time limit2sMemory limit1024 MB
For each query i, find the i-th term of the lexicographically smallest increasing sequence where each positive integer n has exactly one of n, 3n, and 5n in the sequence.
- Level
Medium6 of 10
- Topics
- Number theory, Greedy, Math
- Solved
- No attempts yet
Problem
An infinite increasing sequence of distinct positive integers is the lexicographically smallest sequence that satisfies the following property.
- For every positive integer , exactly one of , , and appears in the sequence.
Given a positive integer , find the value of .
Input
The first line contains the number of test cases (). Each of the next lines contains one value of ().
Output
Print lines. For each , print on its own line.