309744: CF1729A. Two Elevators

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

Description

Two Elevators

题意翻译

现在 Vlad 在一楼,他需要等电梯。公寓有两台电梯。第一台在 $a$ 楼,第二台在 $b$ 楼驶向 $c$ 楼。(若 $b$ $=$ $1$ ,Vlad 也上不了电梯)此时呼叫第一台电梯可以使电梯立刻从 $a$ 楼下来,呼叫第二台电梯可以使电梯先上 $c$ 楼,再下来。已知他们速度均为每秒一层楼,求哪辆电梯来得快。 **【输入格式】** 有 $t$ 组数据,每组有 $a$ $b$ $c$ 三个变量(数据 $\le$ $10^{8}$) **【输出格式】** 共 $t$ 行,每行输出 $1$ $2$ $3$ 中的一个,$1$ 代表第一个电梯较快,$2$ 代表第二个电梯较快,$3$ 代表两个电梯一样快。

题目描述

Vlad went into his appartment house entrance, now he is on the $ 1 $ -th floor. He was going to call the elevator to go up to his apartment. There are only two elevators in his house. Vlad knows for sure that: - the first elevator is currently on the floor $ a $ (it is currently motionless), - the second elevator is located on floor $ b $ and goes to floor $ c $ ( $ b \ne c $ ). Please note, if $ b=1 $ , then the elevator is already leaving the floor $ 1 $ and Vlad does not have time to enter it. If you call the first elevator, it will immediately start to go to the floor $ 1 $ . If you call the second one, then first it will reach the floor $ c $ and only then it will go to the floor $ 1 $ . It takes $ |x - y| $ seconds for each elevator to move from floor $ x $ to floor $ y $ . Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.

输入输出格式

输入格式


The first line of the input contains the only $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. This is followed by $ t $ lines, three integers each $ a $ , $ b $ and $ c $ ( $ 1 \le a, b, c \le 10^8 $ , $ b \ne c $ ) — floor numbers described in the statement.

输出格式


Output $ t $ numbers, each of which is the answer to the corresponding test case. As an answer, output: - $ 1 $ , if it is better to call the first elevator; - $ 2 $ , if it is better to call the second one; - $ 3 $ , if it doesn't matter which elevator to call (both elevators will arrive in the same time).

输入输出样例

输入样例 #1

3
1 2 3
3 1 2
3 2 1

输出样例 #1

1
3
2

说明

In the first test case of the example, the first elevator is already on the floor of $ 1 $ . In the second test case of the example, when called, the elevators would move as follows: - At the time of the call, the first elevator is on the floor of $ 3 $ , and the second one is on the floor of $ 1 $ , but is already going to another floor; - in $ 1 $ second after the call, the first elevator would be on the floor $ 2 $ , the second one would also reach the floor $ 2 $ and now can go to the floor $ 1 $ ; - in $ 2 $ seconds, any elevator would reach the floor $ 1 $ . In the third test case of the example, the first elevator will arrive in $ 2 $ seconds, and the second in $ 1 $ .

Input

题意翻译

现在 Vlad 在一楼,他需要等电梯。公寓有两台电梯。第一台在 $a$ 楼,第二台在 $b$ 楼驶向 $c$ 楼。(若 $b$ $=$ $1$ ,Vlad 也上不了电梯)此时呼叫第一台电梯可以使电梯立刻从 $a$ 楼下来,呼叫第二台电梯可以使电梯先上 $c$ 楼,再下来。已知他们速度均为每秒一层楼,求哪辆电梯来得快。 **【输入格式】** 有 $t$ 组数据,每组有 $a$ $b$ $c$ 三个变量(数据 $\le$ $10^{8}$) **【输出格式】** 共 $t$ 行,每行输出 $1$ $2$ $3$ 中的一个,$1$ 代表第一个电梯较快,$2$ 代表第二个电梯较快,$3$ 代表两个电梯一样快。

Output

**题目大意:**

Vlad 在他的公寓楼入口,目前在 1 楼,他想要呼叫电梯上楼。公寓楼有两台电梯:

1. 第一台电梯当前在 a 楼,静止不动。
2. 第二台电梯当前在 b 楼,正在前往 c 楼(b ≠ c)。注意,如果 b=1,那么电梯已经离开 1 楼,Vlad 将无法进入。

呼叫第一台电梯,它会立即开始前往 1 楼。呼叫第二台电梯,它会先到达 c 楼,然后前往 1 楼。每台电梯从 x 楼移动到 y 楼需要 |x - y| 秒。

Vlad 想要呼叫到达他更快的电梯。帮助他选择。

**输入数据格式:**

第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。

接下来 t 行,每行包含三个整数 a、b 和 c(1 ≤ a, b, c ≤ 10^8,b ≠ c),分别表示题目中描述的楼层编号。

**输出数据格式:**

输出 t 个数字,每个数字是对应测试用例的答案。输出:

- 1,如果呼叫第一台电梯更好;
- 2,如果呼叫第二台电梯更好;
- 3,如果呼叫哪台电梯都一样(两台电梯同时到达)。**题目大意:** Vlad 在他的公寓楼入口,目前在 1 楼,他想要呼叫电梯上楼。公寓楼有两台电梯: 1. 第一台电梯当前在 a 楼,静止不动。 2. 第二台电梯当前在 b 楼,正在前往 c 楼(b ≠ c)。注意,如果 b=1,那么电梯已经离开 1 楼,Vlad 将无法进入。 呼叫第一台电梯,它会立即开始前往 1 楼。呼叫第二台电梯,它会先到达 c 楼,然后前往 1 楼。每台电梯从 x 楼移动到 y 楼需要 |x - y| 秒。 Vlad 想要呼叫到达他更快的电梯。帮助他选择。 **输入数据格式:** 第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。 接下来 t 行,每行包含三个整数 a、b 和 c(1 ≤ a, b, c ≤ 10^8,b ≠ c),分别表示题目中描述的楼层编号。 **输出数据格式:** 输出 t 个数字,每个数字是对应测试用例的答案。输出: - 1,如果呼叫第一台电梯更好; - 2,如果呼叫第二台电梯更好; - 3,如果呼叫哪台电梯都一样(两台电梯同时到达)。

加入题单

算法标签: