#t139. Recamán 数列
Recamán 数列
Recamán Sequence
Problem Description
Xiaoyang recently discovered the interesting Recamán sequence, generated as follows:
- The first term is .
- If is a positive integer and has never appeared in the sequence, then the -th term ; otherwise .
Xiaoyang wants the first terms of the Recamán sequence, sorted in ascending order. Manual calculation is very hard, so he hopes you can solve it for him.
Input Format
The first line contains one positive integer .
Output Format
One line: integers separated by spaces, the first terms of the Recamán sequence sorted in ascending order.
Sample Input
Sample Input 1
5
Sample Input 2
8
Sample Output
Sample Output 1
1 2 3 6 7
Sample Output 2
1 2 3 6 7 12 13 20
Sample Explanation
For the first sample, , and the sequence is generated as:
- ;
- , not a positive integer, so ;
- , not a positive integer, so ;
- , a positive integer and not yet in the sequence, so ;
- , not a positive integer, so .
The first terms are ; sorted ascending they become , matching the output.
Constraints
For all test points, .