시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 102 81 70 83.333%

문제

1부터 N까지의 숫자가 적힌 카드가 있다. 찬유는 이 카드를 가지고 마술을 하려 한다. 마술을 하는 순서는 다음과 같다.

1) 먼저 1부터 N까지의 숫자가 적힌 카드에서 첫 번째 카드를 가장 뒤로 옮긴다. 그러고 나서 첫 번째 카드를 책상 위에 올려놓는다. 그런데 그 카드는 1이 되어야 한다. 2) 그리고 남은 카드 중에서 첫 번째 카드를 가장 뒤로 옮기고, 또 가장 앞에 있는 카드를 가장 뒤로 옮긴다.(2번 반복) 그리고 가장 앞에 있는 카드를 책상 위에 올려놓는다. 그런데 그 카드는 2가 되어야 한다.

3) 또 남은 카드 중에서 첫 번째 카드를 가장 뒤로 옮기고... (3번 반복) 그리고 가장 앞에 있는 카드를 책상위에 올려놓는데 그것은 3이 된다.

4) 또 남은 카드 중에서 첫 번째 카드를 가장 뒤로 옮기고.. (4번 반복) 그리고 가장 앞에 있는 카드를 책상 위에 올려놓는데 그것은 4이다.

5) 위 과정을 계속 반복하여 N번 카드만 남을 때 까지 반복한다.

위와 같은 카드를 하려면 미리 카드의 순서를 알고 있어야 한다. 카드의 개수 N이 주어져 있을 때 위의 마술을 하기 위한 카드의 초기 순서를 구하는 프로그램을 작성하시오.

입력

첫번째 줄에 카드의 개수 N(1≤N≤1,000)이 주어진다.

출력

첫번째 줄부터 N번째 줄까지 차례로 카드의 순서를 출력한다.

예제 입력 1

4

예제 출력 1

2 1 4 3

힌트

1) 2 1 4 3에서 2를 가장 뒤로 옮긴다. (1 4 3 2)
 2) 1을 책상 위에 옮겨놓는다. (4 3 2)
 3) 4 3 2 에서 4, 3을 뒤로 옮긴다. (2 4 3)
 4) 2를 책상 위로 옮겨놓는다. (4 3)
 5) 4 3 에서 가장 앞에 있는 것을 뒤로 3번 옮긴    다. (3 4)
 6) 3을 책상 위로 옮겨놓는다. (4)
 7) 4를 책상 위로 옮겨놓는다. (완료)
 

W3sicHJ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