Bozo is shifting his house. He has some balls and boxes which he has to shift. He now…
- User
Bozo is shifting his house. He has some balls and boxes which he has to shift. He now wonders how large a ball he can fit in a given box. Given the dimensions of a box, help Bozo determine the radius of the largest ball that he can fit in the box. Assume that an inflated ball will be spherical. Input:-
The first line of the input will be T, the number of test cases. Next follows T lines each containing three space separated integers (L, B, H) which are the length, breadth and height of the box respectively.
Output:-
Print T lines each consisting of the radius(correct to 1 decimal place) of the largest ball that Bozo can fit in the box of dimensions corresponding to each test case.
Constraints:
1 ≤ T ≤ 10^5 1 ≤ L, B, H ≤ 10^18
SAMPLE INPUT 3 1 2 3 3 3 7 987548 4578445 9645875456
SAMPLE OUTPUT 0.5 1.5 493774.0
Assistant
We are given T test cases, each with three positive integers L, B, H (length, breadth, height). We need to compute the radius of the largest sphere that can fit inside a rectangular box (rectangular parallelepiped). The largest sphere that can fit inside a rectangular box is limited by the smallest dimension: the sphere must have diameter equal to the smallest side? Actually, for a rectangular box, the largest sphere that can fit inside is limited by the smallest dimension: the diameter cannot exceed the smallest side length. That would give radius = min(L, B, H)/2. However, is that always true? Consider a box that is not a cube: if you put a sphere inside, the sphere can be placed such that it touches three perpendicular faces? The sphere's center would be at distances equal to its radius from each of the faces it touches. The maximum radius is the distance from the center to the nearest face, but you can choose the center such that it is at equal distances from all six faces? Actually, to maximize the sphere, you want to center it at the center of the box (the optimal is symmetric). But the sphere cannot exceed the half-length of any dimension; because if the radius > half of any dimension, the sphere would protrude beyond that face. So the radius is limited by half of the minimum dimension: r <= L/2, r <= B/2, r <= H/2. So r_max = min(L, B, H)/2. That seems trivial.
But the problem statement says "Bozo is shifting his house. He has some balls and boxes which he has to shift. He now wonders how large a ball he can fit in a given box. Given the dimensions of a box, help Bozo determine the radius of the largest ball that he can fit in the box. Assume that an inflated ball will be spherical." That suggests indeed the largest sphere inscribed in a rectangular box: radius = half the smallest side.
But why would the sample output for input (1,2,3) be 0.5? min =1 => 0.5 correct. For (3,3,7) min=3 => radius=1.5 correct. For (987548, 4578445, 9645875456) min=987548 => radius=493774.0 correct. So answer is indeed min/2.
But constraints: T up to 1e5, and L,B,H up to 1e18. So we just read T lines, for each compute min(L,B,H), then compute min/2. But we need output with one decimal place. Since min is an integer, min/2 may be integer or .5. So we need to format to one decimal. For even min, it's integer; output like "2.0". For odd, like "0.5". So essentially we need to output min/2 as a floating point with one decimal. But careful: min can be up to 1e18, dividing by 2 yields up to 5e17, still within double precision? Double can represent integers up to 2^53 exactly (~9e15). 5e17 > 9e15, so double may lose integer precision. But we need output to one decimal place. For odd numbers, we need .5; for even, .0. We can compute using integer arithmetic: if min is even, result = min//2, and print with ".0". If min is odd, result = min//2 (integer division) + 0.5? Actually min/2 = (min // 2) if min even; if odd, it's (min // 2) + 0.5. So we can output as integer part and fractional part. However, we must output exactly one decimal: e.g., 987548/2 = 493774.0 (even). Sample output: 493774.0. So we need to output as integer if even? But they show "493774.0". So we must have decimal point and one digit.
We can do: if min % 2 == 0: print(f"{min//2}.0") else: print(f"{min//2}.5").
But careful: min is integer up to 1e18. min//2 is up to 5e17, which is well within Python's arbitrary precision integers. So printing is fine.
Thus solution: For each test case, read L, B, H as integers (maybe they are large, but Python can handle). Compute m = min(L, B, H). Then output as above.
Given constraints T up to 1e5, input reading needs to be fast: use sys.stdin.read().
Edge Cases: what if dimensions are all equal? That's fine. Also if smallest dimension is 1, then radius = 0.5. Good.
Thus answer: print each line.
But wait: Could there be any other nuance? The largest ball that fits in a rectangular box is indeed limited by the smallest dimension, but is there any possibility to have a larger sphere that fits tilted? Actually, in a rectangular box, a sphere is defined by its shape; no rotation possible. The sphere must be completely inside. The maximum radius is half the smallest dimension. However, there is also the concept of the largest sphere that can fit in a rectangular box could be limited by the space diagonal? For a cuboid, the maximum sphere is inscribed in the box touching the faces, not the corners. It is the insphere of a rectangular parallelepiped? But the insphere exists only if the box is a cube? Wait, the term "insphere" typically applies to a polyhedron that is tangent to all faces. For a rectangular parallelepiped (a box), an insphere exists only if the distances from the center to each face are equal, which would require the box to be a cube. But we are not requiring the sphere to touch all six faces; we only need it to be completely inside. The largest sphere that can fit will be as big as possible without protruding. The best we can do is to make it touch three perpendicular faces (say the ones that are closest) and not necessarily the opposite faces. The maximum radius is limited by the smallest half-dimension, because if we try to make it larger, it would go beyond the smallest dimension face. So the sphere will be centered at the center of the box? Actually, if we center the sphere at the box's center, distances to each pair of opposite faces are equal to half dimensions. The sphere of radius r will be inside if r <= L/2, r <= B/2, r <= H/2. So the maximum r = min(L/2, B/2, H/2). If we shift the center away from the center, we could potentially increase r? For example, in a 2D rectangle, the largest circle that fits is limited by the smallest side; you can't get a circle with diameter larger than the width by shifting. Because if the width is the smaller dimension, any circle of diameter > width will extend beyond that width, regardless of its position. So the maximum radius is min(L, B, H)/2. So it's correct.
Thus solution is trivial.
But why would this problem be given? Possibly there is a twist: the box might be open on one side? No. The problem statement is simple.
Given constraints: up to 1e5 test cases, each up to 1e18, so we need to be efficient.
Thus final solution: read input, compute min, print.
But we must output to one decimal place. For even min: e.g., min=2 -> 1.0. Odd min: 1 -> 0.5. So we implement formatting as described.
Implementation details:
- Use sys.stdin.buffer.read() to read all bytes.
- Parse integers.
- For each test case, compute m = min(L, B, H).
- If m % 2 == 0: out = f"{m//2}.0"
- else: out = f"{m//2}.5"
- Collect outputs in a list and join with '\n' and print.
Alternatively, we could use division and format with one decimal using Python's round? But due to large numbers, using float may cause inaccuracies. So integer method is safer.
But note: m // 2 is integer division floor, e.g., m=1 => 0. So "0.5" correct.
Now check sample: (987548) is even? 987548/2=493774 exactly, so output "493774.0". Sample shows "493774.0". Good.
So solution accepted.
Potential pitfalls: Input may contain trailing spaces, etc.
Complexity: O(T).
Now produce final answer: Provide explanation and code.
But the user asked: "Bozo is shifting his house...". They likely need solution code. In typical CodeChef style, they want code. So I'll output Python code.
Thus final answer. ```python
import sys
def main(): data = sys.stdin.buffer.read().split() if not data: return t = int(data[0]) out_lines = [] idx = 1 for _ in range(t): l = int(data[idx]); b = int(data[idx+1]); h = int(data[idx+2]) idx += 3 m = min(l, b, h) if m % 2 == 0: out_lines.append(f"{m//2}.0") else: out_lines.append(f"{m//2}.5") sys.stdout.write("\n".join(out_lines))
if name == "main": main()