QOJ.ac

QOJ

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

#3868. 边界

Statistics

Bethany 想要铺设她的浴室地板。浴室的宽度为 $w$ 厘米,长度为 $l$ 厘米。如果 Bethany 仅使用 $1 \times 1$ 厘米的基础瓷砖,她总共需要 $w \cdot l$ 块瓷砖。

然而,她有不同的想法:

  • 在地面内部,她想要使用 $1 \times 1$ 的瓷砖。她正好需要 $(w - 2) \cdot (l - 2)$ 块这样的瓷砖。
  • 在地面边界上,她想要使用尺寸为 $1 \times a$ 的瓷砖,其中 $a$ 为某个正整数。瓷砖也可以旋转 90 度。

对于哪些 $a$ 的值,Bethany 可以按照上述方式铺设浴室地板?注意 $a$ 也可以是 1。

输入格式

每个测试包含多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 100$),表示测试用例的数量。接下来是 $t$ 个测试用例的描述。

每个测试用例由单行组成,包含两个整数 $w, l$ ($3 \le w, l \le 10^9$),表示浴室的尺寸。

输出格式

对于每个测试用例,输出一个整数 $k$ ($0 \le k$),表示给定测试用例下 $a$ 的有效值的数量,随后输出 $k$ 个整数 $a_1, a_2, \dots, a_k$ ($1 \le a_i$),即 $a$ 的有效值。$a_1, a_2, \dots, a_k$ 必须按从小到大的顺序排列。

保证在题目限制下,输出包含的整数总数不超过 $200\,000$ 个。

样例

样例输入 1

3
3 5
12 12
314159265 358979323

样例输出 1

3 1 2 3
3 1 2 11
2 1 2

说明

在第一个测试用例中,浴室宽 3 厘米,长 5 厘米。有三个 $a$ 的值使得 Bethany 可以按照题目描述铺设地板,即 $a = 1, a = 2$ 和 $a = 3$。这三种铺设方式如下图所示。

$a = 1 \quad a = 2 \quad a = 3$

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.