atcoder#ARC149D. [ARC149D] Simultaneous Sugoroku
[ARC149D] Simultaneous Sugoroku
Score : points
Problem Statement
There are pieces placed at integer coordinates on a number line. The coordinate of the -th piece is .
Let us move these pieces times as follows.
- In the -th move, given a positive integer , we move each piece as follows.- A piece whose coordinate is a negative integer is moved a distance of in the positive direction.
- A piece whose coordinate is is not moved.
- A piece whose coordinate is a positive integer is moved a distance of in the negative direction.
- A piece whose coordinate is a negative integer is moved a distance of in the positive direction.
- A piece whose coordinate is is not moved.
- A piece whose coordinate is a positive integer is moved a distance of in the negative direction.
Determine whether each piece arrives at the origin. If it does, print the number of moves after which it arrives there for the first time. Otherwise, print its coordinate after the moves.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should describe the -th piece in the following format.
If the piece arrives at the origin, let be the number of moves after which it arrives there for the first time, and print the following:
Yes
If the piece does not arrive at the origin, let be its coordinate after the moves, and print the following:
No
6 4
2 4 6 8 10 12
8 2 5 7
No -6
No -4
Yes 2
Yes 1
Yes 2
No 4
The coordinate of each piece changes as follows.
- The -st piece: $\phantom{0}2\quad \longmapsto \quad -6\quad \longmapsto \quad -4\quad \longmapsto \quad \phantom{-}1 \quad \longmapsto \quad -6$.
- The -nd piece: $\phantom{0}4 \quad \longmapsto \quad -4\quad \longmapsto \quad -2 \quad \longmapsto \quad \phantom{-}3 \quad \longmapsto \quad -4$.
- The -rd piece: $\phantom{0}6 \quad \longmapsto \quad -2\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$.
- The -th piece: $\phantom{0}8 \quad \longmapsto \quad \phantom{-}0\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$.
- The -th piece: $10 \quad \longmapsto \quad \phantom{-}2\quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0 \quad \longmapsto \quad \phantom{-}0$.
- The -th piece: $12 \quad \longmapsto \quad \phantom{-}4\quad \longmapsto \quad \phantom{-}2 \quad \longmapsto \quad -3 \quad \longmapsto \quad \phantom{-}4$.