Consider the infinite integer sequenceSstarting with:
Circle the first occurrence of each integer.
S= ①, 1, ②, 1, ③, 2, ④, 1, ⑤, ⑥, 3, ⑦, 2, ⑧, ⑨, 4, ⑩, 1, ⑪, ⑫, ...
The sequence is characterized by the following properties:
Please find out then-th number in the sequenceS.
There are multiple test cases. The first line of input contains an integerTindicating the number of test cases. For each test case:
There is an integernin one line. (1≤n≤ 1015,T≤ 10000)
For each test case, print an integer indicating the answer in one line.
7
1
2
3
4
5
10
20
1
1
2
1
3
6
12
This problem was inspired by Problem 535 at Project Euler.