Another Contest 9 Problem 1 - Black Room Boy

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 256M

Problem type

Nick is inside a rectangular black room. He knows how far away he is from each of the room's four walls. What are the possible dimensions of the room?

Constraints

1T104

1d1,d2,d3,d410

Input Specification

The first line contains a single positive integer, T, the number of test cases. T test cases follow.

Each test case consists of a single line that contains four space-separated positive integers, d1 through d4. These four integers represent how far Nick is from each of the four walls of the room.

Output Specification

Output the answers for the T test cases in order. There should be no blank lines in your output.

The answer for a test case should take K+1 lines, where K is the number of distinct room dimensions that are attainable. The first line should contain an integer K; then, the next K lines should contain two space-separated integers ai and bi, indicating that a rectangular room of dimensions ai×bi is attainable. These lines should be printed in increasing order of ai, tiebreaking in increasing order of bi.

Sample Input

Copy
2
1 1 1 1
1 2 3 4

Sample Output

Copy
1
2 2
5
3 7
4 6
5 5
6 4
7 3

Comments


  • 0
    kuhn  commented 46 days ago

    no people???