141. Jumping Joe¶
time limit per test: 0.25 sec / memory limit per test: 4096 KB
Joe is a frog who likes to jump a lot. In fact, that’s all he does: he jumps forwards and backwards on the integer axis (a straight line on which all the integer numbers, both positive and negative are marked). At first, Joe sits next to the point marked with 0. From here, he can jump in the positive or the negative direction a distance equal to either \(x_1\) or \(x_2\). From the point where he arrived, he can jump again a distance equal to \(x_1\) or \(x_2\), in the positive or the negative direction and so on.. Joe wants to arrive next to the point marked with the number P, after exactly K jumps. You have to decide whether such a thing is possible.
Input
The input will contain four integers: x1, x2 (0 < x1 , x2 < 40 000), P (-40 000 < P < 40 000) and K (0 <= K < 2 000 000 000), separated by blanks.
Output
Example(s)
| Sample Input | Sample Output |
2 3 -1 12
|
YES
1 0 5 6
|