QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#3897. 拼图

统计

你在阁楼里发现了一套旧拼图,是前房主留下的。因为你喜欢拼图,所以决定把它拼好。但在开始之前,你想知道这套拼图被留下来是否有什么原因。也许它不完整?也许盒子里混入了来自多套拼图的碎片?

如果它看起来是一套完整的拼图,你还需要知道你的工作台需要多大。没有什么比因为桌子太小而不得不重新开始拼图更糟糕的事情了。

盒子没有告诉你拼图的尺寸 $w \times h$,但你可以快速数出盒子里三种碎片的数量:

  • 角部碎片,接触拼图的两条边。
  • 边缘碎片,接触拼图的一条边。
  • 中心碎片,不接触拼图的任何边。

这些碎片能拼成一套完整的拼图吗?如果可以,这套拼图原本的尺寸是多少?

输入格式

输入包含:

  • 一行,包含三个整数 $c, e, m$ ($0 \le c, e, m \le 10^9$),分别代表角部碎片、边缘碎片和中心碎片的数量。

输出格式

如果存在满足 $w \ge h \ge 2$ 的数字 $w$ 和 $h$,使得拼图的原始尺寸可能是 $w \times h$,则输出一行,包含 $w$ 和 $h$。否则,输出 “impossible”。

如果存在多个有效的解,你可以输出其中任意一个。

样例

样例输入 1

4 8 4

样例输出 1

4 4

样例输入 2

4 10 14

样例输出 2

impossible

样例输入 3

4 12 6

样例输出 3

impossible

样例输入 4

4 2048 195063

样例输出 4

773 255

Figure 1. Illustration of various puzzle pieces including corner, edge, and center pieces.

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.