AtCoder Beginner Contest 135
E
Golf
AtCoder
⌀ 2665
原题
← DF →
翻译中…

Problem Statement

翻译中…

Jumbo Takahashi will play golf on an infinite two-dimensional grid.

翻译中…

The ball is initially at the origin $(0, 0)$, and the goal is a grid point (a point with integer coordinates) $(X, Y)$. In one stroke, Jumbo Takahashi can perform the following operation:

翻译中…
  • Choose a grid point whose Manhattan distance from the current position of the ball is $K$, and send the ball to that point.
翻译中…

The game is finished when the ball reaches the goal, and the score will be the number of strokes so far. Jumbo Takahashi wants to finish the game with the lowest score possible.

翻译中…

Determine if the game can be finished. If the answer is yes, find one way to bring the ball to the goal with the lowest score possible.

翻译中…

What is Manhattan distance? The Manhattan distance between two points $(x_1, y_1)$ and $(x_2, y_2)$ is defined as $|x_1-x_2|+|y_1-y_2|$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \leq K \leq 10^9$
  • $-10^5 \leq X, Y \leq 10^5$
  • $(X, Y) \neq (0, 0)$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

K
X Y

翻译中…

Output

翻译中…

If the game cannot be finished, print -1.

翻译中…

If the game can be finished, print one way to bring the ball to the destination with the lowest score possible, in the following format:

翻译中…

s
x_1 y_1
x_2 y_2
.
.
.
x_s y_s

翻译中…

Here, $s$ is the lowest score possible, and $(x_i, y_i)$ is the position of the ball just after the $i$-th stroke.

翻译中…

样例

Input #1
11
-1 2
Output #1
3
7 4
2 10
-1 2
- The Manhattan distance between $(0, 0)$ and $(7, 4)$ is $|0-7|+|0-4|=11$. - The Manhattan distance between $(7, 4)$ and $(2, 10)$ is $|7-2|+|4-10|=11$. - The Manhattan distance between $(2, 10)$ and $(-1, 2)$ is $|2-(-1)|+|10-2|=11$. Thus, this play is valid. Also, there is no way to finish the game with less than three strokes.
Input #2
4600
52 149
Output #2
-1
Input #3
4
9 9
Output #3
5
1 3
4 2
4 6
6 8
9 9
题目信息
题号
abc135_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。