3385. Skinny Polygon

单点时限: 2.0 sec

内存限制: 256 MB

You are asked to find a polygon that satisfies all the following conditions, given two integers, xb and yb.

  • The number of vertices is either 3 or 4.
  • Edges of the polygon do not intersect nor overlap with other edges, i.e., they do not share any points with other edges except for their endpoints.
  • The x- and y-coordinates of each vertex are integers.
  • The x-coordinate of each vertex is between 0 and xb , inclusive. Similarly, the y-coordinate is between 0 and yb, inclusive.
  • At least one vertex has its x-coordinate 0.
  • At least one vertex has its x-coordinate xb.
  • At least one vertex has its y-coordinate 0.
  • At least one vertex has its y-coordinate yb.
  • The area of the polygon does not exceed 25000.

The polygon may be non-convex.

输入格式

The input consists of multiple test cases. The first line of the input contains an integer n, which is the number of the test cases (1n105). Each of the following n lines contains a test case formatted as follows.

xb yb

xb and yb (2xb109,2yb109) are integers stated above.

输出格式

For each test case, output description of one polygon satisfying the conditions stated above, in the following format.

v
x1 y1
.
.
.
xv yv

Here, v is the number of vertices, and each pair of xi and yi gives the coordinates of the i-th vertex, (xi,yi). The first vertex (x1,y1) can be chosen arbitrarily, and the rest should be listed either in clockwise or in counterclockwise order.
When more than one polygon satisfies the conditions, any one of them is acceptable. You can prove that, with the input values ranging as stated above, there is at least one polygon satisfying the conditions.

样例

Input
2
5 6
1000000000 2
Output
4
5 6
0 6
0 0
5 0
3
1000000000 0
0 2
999999999 0

2 人解决,9 人已尝试。

3 份提交通过,共有 35 份提交。

9.6 EMB 奖励。

创建: 7 年,6 月前.

修改: 5 年,9 月前.

最后提交: 4 年,5 月前.

来源: ICPC Asia Tsukuba Regional 2016

题目标签