当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6653:Halt Hater

题目描述
Cuber QQ has recently won a million dollars and bought a new car. He is now driving in the Infinite City and he doesn't want his car to stop, ever!

The Infinite City, looks like an infinite grid, with infinite streets built at all possible $x$'s and $y$'s when they are integers. The following picture, looks like part of this city. (The picture is downloaded from a webpage, which is certainly not describing the Infinite City.)



There are traffic lights installed on every crossings. Just like what Chinese people usually do, the traffic lights only show signals for left and straight and you can always turn right regardless of the traffic light. The estimate time of waiting for a left turn is $a$, at all crossings; and the time of waiting for a straight is $b$.

Cuber QQ is now driving from $(0, -1)$ to $(0, 0)$, about to entering the crossing at $(0, 0)$. At a crossing, he can choose to go straight, turn left or turn right. He wishes to go to $(x, y)$, but here is a weird request: he wants to have the least estimated traffic light waiting time. In other words, he doesn't care whether he has to drive a long way, or he has to burn a lot of gas, all he wants is to wait as little as possible.

Note that Cuber QQ doesn't have to wait for the traffic light at $(x, y)$; he also doesn't care from which direction he enters $(x, y)$.
输入解释
The first line of the input contains an integer $t$ ($1 \le t \le 100~000$).

Then follows $t$ test cases, each containing $a$, $b$, $x$, $y$ ($1 \le a, b \le 10^9$, $-10^9 \le x, y \le 10^9$, $|x| + |y| > 0$), space separated.
输出解释
For each test case, output one integer as the answer.
输入样例
4
9 1 0 2
2 1 8 0
2 3 3 3
1 1 -1 -1
输出样例
2
7
6
1
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6653

最后修改于 2020-10-25T23:33:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 524288/524288K(Java/Others)