408414: GYM103115 H cocktail with pony

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. cocktail with ponytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

There is a cute pony! Oh No, why a wolf chasing it behind?

In a 1*n one-dimensional number axis, the wolf initial position is point $$$x_1$$$, and the pony at point $$$x_2$$$ initially. Each round, the wolf must move $$$v_1$$$ steps, the pony must move $$$v_2$$$ steps. Each step can move one point to the left or right.

Now the pony and the wolf take turns to move. The pony moves first in the first round, then the wolf moves in the second round, and so on.

Means, the pony moves in the 1, 3, 5, 7, 9... rounds, and the wolf moves in the 2, 4, 6, 8... rounds.

If at a certain moment, the wolf and the pony stand in the same position, it means that the wolf has caught the pony. This moment can be in the process of moving.

It is guaranteed that at the beginning, the little pony and the wolf are not in the same point.

The pony wants to delay the rounds he be caught as many as possible, while the wolf hopes to catch the pony earlier. If both the wolf and the little pony are smart enough, in the first few rounds, will the wolf catch the little pony?

Note: During the movement of the wolf or the little horse, they cannot exceed the boundary of the number axis, that is, any position x they move to must satisfy $$$1 \leq x \leq n$$$

Input

The first line of input contains a positive integer T, which represents the number of test cases.$$$(1 \leq T \leq 10^4)$$$

Each test contains five positive integers $$$n, v_1, v_2, x_1, x_2( 2 \leq n \leq 10^3,1 \leq v_1,v_2\leq 10^9, 1 \leq x_1,x_2 \leq n)$$$ and guarantee $$$x_1 \neq x_2 $$$.

The meaning is as shown in the statement.

Output

For each test data, output a positive integer in one line to indicate that the wolf needs several rounds to catch the pony.

ExampleInput
1
10 3 1 4 8
Output
4
Note

The pony moves to position 9 in the first round, and the wolf moves to position 7 in the second round. In the third round, the little pony must move, so it can only move to position 8 or 10. No matter which position it is, the wolf can catch up in the fourth round. So output 4.

加入题单

算法标签: