QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#1759. 积分金字塔

Statistiques

帕斯卡三角是组合数学世界中的一个奇迹,而且你可以在家里轻松地构建一个。

最底层有 $n$ 个数字。上一行是交错排列的,共有 $n-1$ 个数字,其中第 $i$ 个数字是前一行中第 $i$ 个和第 $i+1$ 个数字之和。

你可以为最底层选择任意正整数,但顶层唯一的单元格必须等于给定的 $x$。这可能吗?

输入格式

  • 唯一的一行包含行数 $n$ ($1 \le n \le 20$) 以及顶层所需的值 $x$ ($1 \le x \le 10^9$)。

输出格式

如果可以构建出这样的金字塔,请输出每一行的所有数字,从顶层开始。每个数字必须大于或等于 1。

否则,输出 impossible

样例

样例输入 1

3 15

样例输出 1

15
8 7
3 5 2

样例输入 2

6 789

样例输出 2

789
394 395
209 185 210
117 92 93 117
70 47 45 48 69
45 25 22 23 25 44

样例输入 3

20 1

样例输出 3

impossible

Figure 1. 帕斯卡三角金字塔示例

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.