Bit Component

시간 제한1초메모리 제한2048 MB

요약
1부터 n까지의 수를 오른쪽 정렬한 이진수 행으로 적을 때 1 비트가 변으로 이어진 한 영역을 이루도록 순서를 정할 수 있는지 판정하고, 가능하면 그 순서를 출력한다.
난이도

보통10점 중 7점

유형
그리디, 구현, 비트 연산
정답자
아직 제출이 없습니다

문제

Denis really likes binary representation of numbers. Once he wrote down binary representations of numbers from 11 to 77, in some order, one under the other, so that their rightmost digits were aligned. Then he realized that the ones in these numbers form a single connected region: if we consider the places for digits as squares on a grid, all squares containing ones are connected by sides. Now he wonders if the same thing can be done for numbers from 11 to nn for different nn.

You are given an integer nn. You should find a good permutation of all integers from 11 to nn, or determine that there is no such permutation. A permutation is good if, when we write the numbers down as described above, the ones form a single connected region.

입력

The only line contains a single integer nn (1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5).

출력

If there is no good permutation of numbers from 11 to nn, print a single line with the word "NO" (uppercase). Otherwise, print a line with the word "YES" (uppercase), and then another line containing the good permutation you found. If there are several possible answers, print any one of them.

힌트

Third example

예제3

  1. 예제 1

    입력
    1
    
    예상 출력
    YES
    1
    
  2. 예제 2

    입력
    2
    
    예상 출력
    NO
    
  3. 예제 3

    입력
    3
    
    예상 출력
    YES
    2 3 1