2474. Star Wars

单点时限: 2.0 sec

内存限制: 256 MB

Near the planet Mars, in a faraway galaxy eerily similar to our own, there is a fight to the death between the imperial forces and the rebels. The rebel army has N ships which we will consider as points (xi, yi, zi). Each ship has a receiver with power pi. The rebel army needs to be able to send messages from the central cruiser to all the ships, but they are tight on finances, so they cannot afford a strong transmitter.

If the cruiser is placed at (x, y, z), and one of the other ships is at (xi, yi, zi) and has a receiver of power pi, then the power of the cruiser’s transmitter needs to be at least:

(|xi - x| + |yi - y| + |zi - z|) / pi

Your task is to find the position for the cruiser that minimizes the power required for its transmitter, and to output that power.

输入格式

The first line of input gives the number of cases, T(1 ≤ T ≤ 11). T test cases follow.

Each test case contains on the first line the integer N(1 ≤ N ≤ 1000), the number of ships in the test case.

N lines follow, each line containing four integer numbers xi, yi, zi(0 ≤ xi, yi, zi ≤ 106) and pi(1 ≤ pi ≤ 106), separated by single spaces. These are the coordinates of the i-th ship, and the power of its receiver. There may be more than one ship at the same coordinates.

输出格式

For each input case, you should output:

Case #X: Y

where X is the number of the test case and Y is the minimal power that is enough to reach all the fleet’s ships. Answers with a relative or absolute error of at most 10-6 will be considered correct.

样例

Input
3
4
0 0 0 1
1 2 0 1
3 4 0 1
2 1 0 1
1
1 1 1 1
3
1 0 0 1
2 1 1 4
3 2 3 2
Output
Case #1: 3.500000
Case #2: 0.000000
Case #3: 2.333333
Hint:
In the first test case, the four ships have coordinates (0, 0, 0), (1, 2, 0), (3, 4, 0), (2, 1, 0) and powers 1, 1, 1, 1 respectively. We can place a cruiser with the power 3.5 at the coordinates (1.5, 2, 0) which will be able to reach all the ships.
In the second case we can place the cruiser right on top of the ship, with transmitter power 0.

2 人解决,4 人已尝试。

2 份提交通过,共有 8 份提交。

9.1 EMB 奖励。

创建: 15 年,8 月前.

修改: 6 年,10 月前.

最后提交: 3 年,12 月前.

来源: GCJ 2008

题目标签