Broken
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
In a rectangular coordinate system, a point M(x, y) is given. Connect point M to the origin using a broken line such that each adjacent segment of the line is perpendicular to the next, and each segment has a length of 1. Determine the shortest possible length of this broken line.
Input Data
The input consists of a single line containing two numbers, which are the coordinates of point M (x, y)
; where ( |x
| , |y
| < 100).
Output Data
The first line should contain the number n
, which represents the number of segments. This is followed by n+1 pairs of numbers, which are the vertices of the broken line.
Examples
Input #1
Answer #1
Submissions 957
Acceptance rate 10%