#K42902. Honeybee Movement Possibility
Honeybee Movement Possibility
Honeybee Movement Possibility
The problem involves determining whether a honeybee can reach a target flower from its initial position by using fixed horizontal and vertical moves. The honeybee starts at coordinates \( (b_x, b_y) \) and wants to reach the flower at \( (f_x, f_y) \). In each move, the honeybee moves exactly \( h \) units horizontally and \( v \) units vertically. The goal is to decide if it is possible to get from the starting position to the destination.
The conditions to reach the destination are as follows:
- The absolute differences \( d_x = |f_x - b_x| \) and \( d_y = |f_y - b_y| \) must be multiples of \( h \) and \( v \) respectively, i.e. \( d_x \bmod h = 0 \) and \( d_y \bmod v = 0 \).
- Moreover, the number of steps taken horizontally \( (d_x / h) \) and vertically \( (d_y / v) \) must have the same parity (both even or both odd).
Output POSSIBLE if the destination can be reached based on the given conditions, otherwise output IMPOSSIBLE.
inputFormat
The input consists of a single line containing six space-separated integers:
- \( b_x \): the x-coordinate of the honeybee
- \( b_y \): the y-coordinate of the honeybee
- \( f_x \): the x-coordinate of the flower
- \( f_y \): the y-coordinate of the flower
- \( h \): the fixed horizontal move
- \( v \): the fixed vertical move
Input is provided via stdin
.
outputFormat
Output a single line containing either POSSIBLE
or IMPOSSIBLE
(without quotes) depending on whether the honeybee can reach the flower. The output is sent to stdout
.
1 1 4 7 3 2
POSSIBLE