#P16226. [蓝桥杯 2026 省 A] 拦截程序

[蓝桥杯 2026 省 A] 拦截程序

Problem Description

The Federal Security Bureau has intercepted an ongoing hacking attack: a data packet carrying core secrets is being secretly transmitted along a linear fiber tunnel.

The total length of the fiber tunnel is LL. You can treat it as a line segment from coordinate 00 (left end) to coordinate LL (right end). Intelligence shows that the packet moves inside the fiber at a constant speed VV, and it has been transmitted for exactly TT seconds. That is, it has moved a distance of V×TV \times T inside the fiber.

The source of the intrusion is still unclear, so the current position of the packet has two possibilities:

  1. Case A (intrusion from the left end): the packet is at coordinate PA=V×TP_A = V \times T.
  2. Case B (intrusion from the right end): the packet is at coordinate PB=L−V×TP_B = L - V \times T.

You need to choose an integer coordinate PP (0≤P≤L0 \le P \le L) on the fiber to deploy an interception program.

To make the plan as reliable as possible, you need to measure the deviation at each coordinate PP: the larger one of the distance from PP to PAP_A and the distance from PP to PBP_B.

Now, find the best integer coordinate PP that minimizes this deviation, and output the minimum value.

Input Format

The first line contains an integer CC, the number of test cases.

The next CC lines each contain three integers L,V,TL, V, T, representing the total length of the fiber tunnel, the packet's moving speed, and the time it has been transmitted.

Output Format

For each test case, output one integer per line, representing the minimum deviation value.

3
100 2 10
51 5 2
200 10 10
30
16
0

Hint

Sample Explanation

For the first test case, L=100,V=2,T=10L = 100, V = 2, T = 10: the packet has moved 2020. It may be in Case A (coordinate 2020) or in Case B (coordinate 8080). Choose the integer coordinate P=50P = 50. No matter which side it is on, the distance is 3030.

For the second test case, L=51,V=5,T=2L = 51, V = 5, T = 2: the packet has moved 1010. It may be in Case A (coordinate 1010) or in Case B (coordinate 4141). The best integer coordinate can be P=25P = 25: the distance to A is 1515, and the distance to B is 1616, so the larger one is 1616. Or choose P=26P = 26: the distance to A is 1616, and the distance to B is 1515, and the larger one is also 1616. Therefore, the minimum worst-case distance is 1616.

For the third test case, L=200,V=10,T=10L = 200, V = 10, T = 10: the packet has moved 100100. No matter which side it started from, it is now exactly at the center coordinate 100100. Deploy the program directly at P=100P = 100, and the maximum distance is 00.

Constraints and Notes

For 30%30\% of the test cases, 1≤C≤1001 \le C \le 100, 1≤L,V,T≤10001 \le L, V, T \le 1000.

For all test cases, 1≤C≤1051 \le C \le 10^5, 1≤L,V,T≤10121 \le L, V, T \le 10^{12}, and it is guaranteed that V×T≤LV \times T \le L. In particular, the testdata additionally satisfies V×T<L/2V \times T < L / 2, but this is not stated in the original problem statement.

Translated by ChatGPT 5