[SNCPC2019] Pick Up

题意翻译

**【题目描述】** 格子城是一个位于无限二维平面上的城市,其中对于所有 $k \in \mathbb{Z}$($\mathbb{Z}$ 是所有整数的集合),直线 $x = k$ 和 $y = k$ 是城市的街道。人们只能沿着道路从一个位置移动到另一个位置。这就是为什么这个城市被称为格子城! 两个朋友,宝宝和梦想格子,快乐地生活在这个城市里。今天宝宝正从他位于 $(x_A, y_A)$($x_A, y_A \in \mathbb{Z}$)的家出发,前往位于 $(x_C, y_C)$($x_C, y_C \in \mathbb{Z}$)的购物中心。然而,这段路对他来说太远了,所以他决定叫住在 $(x_B, y_B)$($x_B, y_B \in \mathbb{Z}$)的梦想格子来帮忙。 宝宝和梦想格子同时从他们的家出发。不同于以每分钟 $a$ 个单位速度步行的宝宝,梦想格子开车并以每分钟 $b$ 个单位速度移动。当梦想格子和宝宝在同一个点相遇时,梦想格子可以接上宝宝,然后他们可以一起以每分钟 $b$ 个单位速度移动。转身或接上宝宝不需要时间。 从宝宝的家到购物中心所需的最短时间是多少?请注意,如果梦想格子接上宝宝会更慢,则不需要梦想格子接宝宝。 **【输入格式】** 有多个测试用例。输入的第一行包含一个整数 $T$($1 \le T \le 10^5$),表示测试用例的数量。对于每个测试用例: 第一行包含两个整数 $a$ 和 $b$($1 \le a < b \le 10^9$),表示宝宝的步行速度和梦想格子的驾驶速度。 第二行包含六个整数 $x_A$,$y_A$,$x_B$,$y_B$,$x_C$ 和 $y_C$($-10^9 \le x_A, y_A, x_B, y_B, x_C, y_C \le 10^9$),表示宝宝的家、梦想格子的家和购物中心的位置。保证这三点互不相同。 **【输出格式】** 对于每个测试用例,输出一行,包含一个数字,表示宝宝到达购物中心的最短时间。如果你的答案的绝对误差或相对误差不超过 $10^{-6}$,则将被视为正确。 **【样例解释】** 对于第一个样例测试用例,宝宝和梦想格子将在 $D(1,2)$ 相遇,然后梦想格子载着宝宝去购物中心。 对于第二个样例测试用例,宝宝和梦想格子将在 $D(1.5,1)$ 相遇,然后梦想格子载着宝宝去购物中心。 翻译来自于:[ChatGPT](https://chatgpt.com/)。

题目描述

Grid City is a city on an infinite two-dimensional plane, where for all $k \in \mathbb{Z}$ ($\mathbb{Z}$ is the set of all integers) lines $x = k$ and $y = k$ are the streets of the city. People can only move along the roads to go from one position to another. That's why the city is called the Grid City! Two friends, BaoBao and DreamGrid, live happily in the city. Today BaoBao is heading from his home positioned at $(x_A, y_A)$ ($x_A, y_A \in \mathbb{Z}$) towards the shopping mall positioned at $(x_C, y_C)$ ($x_C, y_C \in \mathbb{Z}$). However, it's too far for him to walk there, so he decides to call DreamGrid whose home is positioned at $(x_B, y_B)$ ($x_B, y_B \in \mathbb{Z}$) for help. BaoBao and DreamGrid set out separately from their homes at the same time. Different from BaoBao who walks at a speed of $a$ units per minute, DreamGrid drives a car and moves at a speed of $b$ units per minute. When DreamGrid and BaoBao meet at the same point, DreamGrid can pick up BaoBao and they can then move at a speed of $b$ units per minute together. It takes no time to turn around or pick up BaoBao. What's the minimum time needed for BaoBao to go from his home to the shopping mall? Note that it's NOT necessary for DreamGrid to pick up BaoBao if it will be faster for BaoBao to get to the destination.

输入输出格式

输入格式


There are multiple test cases. The first line of the input contains an integer $T$($ 1 \le T \le 10^5$), indicating the number of test cases. For each test case: The first line contains two integers $a$ and $b$ ($1 \le a < b \le 10^9$), indicating the walking speed of BaoBao and the driving speed of DreamGrid. The second line contains six integers $x_A$, $y_A$, $x_B$, $y_B$, $x_C$ and $y_C$ ($-10^9 \le x_A, y_A, x_B, y_B, x_C, y_C \le 10^9$), indicating the position of BaoBao's home, DreamGrid's home and the shopping mall. It's guaranteed that these three points are different from each other.

输出格式


For each test case output one line containing one number, indicating the shortest time for BaoBao to arrive at the shopping mall. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$.

输入输出样例

输入样例 #1

3
1 2
0 2 1 0 2 2
1 3
1 1 0 1 3 1
1 2
0 0 100 100 1 1

输出样例 #1

1.500000000000000
1.000000000000000
2.000000000000000

说明

For the first sample test case, BaoBao and DreamGrid will meet at $D(1,2)$ and then DreamGrid drives BaoBao to the shopping mall. For the second sample test case, BaoBao and DreamGrid will meet at $D(1.5,1)$ and then DreamGrid drives BaoBao to the shopping mall. ![](https://cdn.luogu.com.cn/upload/image_hosting/wexb0vmz.png)