QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#2701. 令人印象深刻的整数

الإحصائيات

最近,Alice 和她的妹妹 Clara 了解到了“可爱数”(adorable numbers):如果存在整数 $a, b$ 和 $c$,使得一个边长为 $c$ 的等边三角形可以被 $n$ 个边长分别为 $a$ 或 $b$ 的较小等边三角形所覆盖,那么正整数 $n$ 就被称为可爱数。例如,6 是一个可爱数,如图 I.1a 所示。

图 I.1

她们决定看看谁能找出更多的可爱数,但手动检查所有数字太麻烦了。因此,Alice 请你帮她检查 Clara 列出的数字是否为可爱数。由于她想确保每个被声称是可爱数的数字确实是可爱数,她请你编写一个程序,给定一个整数 $n$,判断它是否为可爱数,如果是,则输出如图 I.1a 所示的有效平铺方案。

输入格式

输入包含: * 一个正整数 $n$ ($1 \le n \le 1000$)。

输出格式

如果给定的整数 $n$ 是可爱数,请使用以下格式输出一种有效的平铺方案: 三个整数 $a, b, c$ ($1 \le a, b \le c \le 10^9$),使得边长为 $c$ 的等边三角形可以被 $n$ 个边长为 $a$ 和 $b$ 的等边三角形平铺。 $n$ 行,每行描述一个三角形,包含: AB 中的一个,指定三角形的边长是 $a$ 还是 $b$; 两个整数 $x, y$,给出三角形的最左侧顶点坐标; * UD 中的一个,指定三角形是向上还是向下指向。

这些三角形必须构成一个对顶点位于 $(0, 0), (0, c)$ 和 $(c, 0)$ 的等边三角形的有效平铺,其中所有坐标均使用图 I.1b 中的坐标系给出。

否则,如果 $n$ 不是可爱数,输出 impossible

如果你的平铺方案由大小相同的三角形组成,你可以全部使用 A 或全部使用 B,或者令 $a = b$ 并任意将每个三角形标记为 AB

可以证明,对于输入范围内的每一个可爱数,都可以按照上述规则构造出一种平铺方案。你可以输出任何一种有效的平铺方案。

样例

样例输入 1

2

样例输出 1

impossible

样例输入 2

6

样例输出 2

1 2 3
B 0 1 U
A 0 0 U
A 0 1 D
A 1 0 U
A 1 1 D
A 2 0 U

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.