The Filter
시간 제한2초메모리 제한1024 MB
N이 주어질 때, 분수 x/N이 칸토어 집합에 속하는 모든 정수 x(0 ≤ x ≤ N)를 오름차순으로 출력한다.
문제
Alice, the mathematician, likes to study real numbers that are between and . Her favourite tool is the filter.
A filter covers part of the number line. When a number reaches a filter, two events can happen. If a number is not covered by the filter, the number will pass through. If a number is covered, the number will be removed.
Alice has infinitely many filters. Her first filters look like this:
In general, the -th filter can be defined as follows:
- Consider the number line from to .
- Split this number line into equal-sized pieces. There are points and intervals.
- The -th filter consists of the interval, interval, interval, and in general, the interval. The points are not part of the -th filter.
Alice has instructions for constructing the Cantor set. Start with the number line from to . Apply all filters on the number line, and remove the numbers that are covered. The remaining numbers form the Cantor set.
Alice wants to research the Cantor set, and she came to you for help. Given an integer , Alice would like to know which fractions are in the Cantor set.
입력
The first line contains the integer .
출력
Output all integers where and is in the Cantor set.
Output the answers in increasing order. The number of answers will not exceed .