Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 65536 KB / Others: 65536 KB

There is an interesting and simple one person game. Suppose there is a number axis under your feet. You are at point A at first and your aim is point B. There are 6 kinds of operations you can perform in one step. That is to go left or right by a,b and c, here c always equals to a+b.

You must arrive B as soon as possible. Please calculate the minimum number of steps.

There are multiple test cases. The first line of input is an integer T(0 < T ≤ 1000) indicates the number of test cases.
Then T test cases follow.
Each test case is represented by a line containing four integers 4 integers A, B, a and b, separated by spaces. (-2^{31} ≤ A, B < 2^{31}, 0 < a, b < 2^{31})

提交代码