Horse Training
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Petro loves special horses very much, so he named his sport
programming team Stallions. Right now, Petro is incredibly
rushing to his team’s training, because he knows that without him they
won’t solve a single problem. Petro believes that his teammates will
soon also learn to solve problems as skillfully as he does.
Although Petro does sport programming and can undoubtedly be considered an athlete, he runs rather slowly. Petro can only run at a speed of 1 meter per hour. He is in a great hurry to the training and wants to catch a tram so as not to be late. Petro lives on Tarnavskyi Street and his house is located \(x\) meters from the beginning of the street. The tram that Petro wants to catch is currently at the beginning of this street and it moves at a speed of \(v\) meters per hour. Petro’s house is located strictly between two stops, which are located at \(a\) and \(b\) meters from the beginning of the street. To catch the tram at a stop, he needs to arrive there no later than the tram arrives. Petro is a very smart guy, so he will optimally choose the stop to which he should run.
Determine which stop Petro will run to in order to catch his team’s
training. If he can catch it at either stop, he will go to the one that
is closer to his home. If he manages to reach both stops and they are at
the same distance from his home, then output the stop with the smaller
coordinate. If he does not make it to the training, output
-1.
Input
The single line contains four integers \(v\), \(x\), \(a\) and \(b\) — the speed of the tram, the distance from the beginning of the street to Petro’s house, and both stops respectively.
Output
In a single line, output the number of the stop to which Petro will
run, or -1 if he does not make it to the training. If Petro
runs to the stop with coordinate \(a\),
output 1, if with coordinate \(b\), output 2.
Constraints
\(2 \le v \le 10\),
\(1 \le a < x < b \le 10^9\),
\(v\) is a divisor of \(a\) and \(b\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 6 4 12 | 1 |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 20 12 60 | -1 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|