QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22580. 숫자의 합 거꾸로 구하기

Statistics

FJ와 그의 소들은 머리를 쓰는 게임을 즐깁니다. $1$부터 $N$ ($1 \le N \le 10$)까지의 수를 어떤 순서로 적은 다음, 인접한 수를 더하여 수가 하나 적은 새 목록을 만듭니다. 수가 하나만 남을 때까지 이를 반복합니다. 예를 들어 $N=4$일 때 게임은 다음과 같이 진행될 수 있습니다.

3   1   2   4
  4   3   6
    7   9
     16

소들은 FJ 몰래 더 어려운 게임을 시작했습니다. 최종 합과 수 $N$만으로 처음 수열을 알아내는 게임입니다. 안타깝게도 이 게임은 FJ의 암산 능력을 조금 넘어섭니다.

FJ가 게임을 하며 소들을 따라갈 수 있도록 돕는 프로그램을 작성하세요.

입력

  • 1번째 줄: 공백으로 구분된 두 정수 $N$과 최종 합.

출력

  • 1번째 줄: 주어진 합을 만드는 정수 $1..N$의 배열 순서. 답이 여러 개라면 사전 순으로 가장 작은 것, 즉 더 작은 수를 먼저 놓는 것을 선택합니다.

예제

입력 1

4 16

출력 1

3 1 2 4

참고

$3,2,1,4$와 같은 다른 수열도 가능하지만, $3,1,2,4$가 사전 순으로 가장 작습니다.

문제 작성: Harry Wiggins (2002).

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.