CF1662H.Boundary
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bethany would like to tile her bathroom. The bathroom has width w centimeters and length l centimeters. If Bethany simply used the basic tiles of size 1×1 centimeters, she would use w⋅l of them.
However, she has something different in mind.
- On the interior of the floor she wants to use the 1×1 tiles. She needs exactly (w−2)⋅(l−2) of these.
- On the floor boundary she wants to use tiles of size 1×a for some positive integer a. The tiles can also be rotated by 90 degrees.
For which values of a can Bethany tile the bathroom floor as described? Note that a can also be 1.
贝丝妮想用瓷砖铺满她的浴室。浴室的宽度为 w 厘米,长度为 l 厘米。如果贝丝妮仅使用基本的 1×1 厘米瓷砖,则总共需要 w⋅l 块。
然而,她另有打算:
- 在地板内部区域,她打算使用 1×1 的瓷砖,恰好需要 (w−2)⋅(l−2) 块;
- 在地板边界区域,她打算使用尺寸为 1×a 的瓷砖(其中 a 为某个正整数),且这些瓷砖可沿 90∘ 方向旋转。
对于哪些 a 的取值,贝丝妮能按上述方式铺满整个浴室地板?注意:a 也可以等于 1。
输入格式
Each test contains multiple test cases. The first line contains an integer t (1≤t≤100) — the number of test cases. The descriptions of the t test cases follow.
Each test case consist of a single line, which contains two integers w, l (3≤w,l≤109) — the dimensions of the bathroom.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。接下来是 t 个测试用例的描述。
每个测试用例由一行组成,包含两个整数 w、l(3≤w,l≤109),表示浴室的尺寸。
输出格式
For each test case, print an integer k (0≤k) — the number of valid values of a for the given test case — followed by k integers a1,a2,…,ak (1≤ai) — the valid values of a. The values a1,a2,…,ak have to be sorted from smallest to largest.
It is guaranteed that under the problem constraints, the output contains at most 200000 integers.
对于每个测试用例,输出一个整数 k(0≤k)—— 表示该测试用例下合法的 a 值的个数 —— 然后输出 k 个整数 a1,a2,…,ak(1≤ai)—— 即所有合法的 a 值。这些值 a1,a2,…,ak 必须按从小到大的顺序排列。
在本题约束条件下,保证输出中整数的总数不超过 200000 个。
输入输出样例
输入#1
3 3 5 12 12 314159265 358979323
输出#1
3 1 2 3 3 1 2 11 2 1 2
说明/提示
In the first test case, the bathroom is 3 centimeters wide and 5 centimeters long. There are three values of a such that Bethany can tile the floor as described in the statement, namely a=1, a=2 and a=3. The three tilings are represented in the following pictures.

在第一个测试用例中,浴室宽 3 厘米、长 5 厘米。存在三个满足题干所述条件的 a 值,使得贝丝妮能够按要求铺满地面,即 a=1、a=2 和 a=3。这三种铺法如以下图片所示。

输入解题思路,AI测评打分。不知道怎么写?