Boundary
Time limit2sMemory limit2048 MB
For a w by l rectangle, find every a such that the 1-wide boundary ring can be tiled by 1 by a tiles, listing them in order.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
Bethany would like to tile her bathroom. The bathroom has width centimeters and length centimeters. If Bethany uses only basic centimeter tiles, she needs of them.
She has something else in mind.
- On the interior of the floor, she uses tiles. She needs exactly of these.
- On the floor boundary, she uses tiles of size for some positive integer . The tiles can also be rotated by degrees.
For which values of can Bethany tile the bathroom floor as described? Note that can also be .
Input
Each test contains multiple test cases. The first line contains an integer (), the number of test cases. Each of the following lines contains two integers and (), the dimensions of the bathroom.
Output
For each test case, print an integer (), the number of valid values of , followed by the valid values in increasing order. It is guaranteed that under the problem constraints, the output contains at most integers.