#P13438. [GCJ 2009 #1C] Center of Mass
[GCJ 2009 #1C] Center of Mass
题目描述
You are studying a swarm of fireflies. Each firefly is moving in a straight line at a constant speed. You are standing at the center of the universe, at position . Each firefly has the same mass, and you want to know how close the center of the swarm will get to your location (the origin).
You know the position and velocity of each firefly at , and are only interested in . The fireflies have constant velocity, and may pass freely through all of space, including each other and you. Let be the location of the center of mass of the fireflies at time . Let be the distance between your position and at time . Find the minimum value of , , and the earliest time when , .
输入格式
The first line of input contains a single integer , the number of test cases. Each test case starts with a line that contains an integer , the number of fireflies, followed by lines of the form
Each of these lines describes one firefly: is its initial position at time , and is its velocity.
输出格式
For each test case, output
Case #:
where is the test case number, starting from 1. Any answer with absolute or relative error of at most will be accepted.
3
3
3 0 -4 0 0 3
-3 -2 -1 3 0 0
-3 -1 2 0 3 0
3
-5 0 0 1 0 0
-7 0 0 1 0 0
-6 3 0 1 0 0
4
1 2 3 1 2 3
3 2 1 3 2 1
1 0 0 0 0 -1
0 10 0 0 -10 -1
Case #1: 0.00000000 1.00000000
Case #2: 1.00000000 6.00000000
Case #3: 3.36340601 1.00000000
提示
Notes
Given points , their center of the mass is the point , where:
Limits
- All the numbers in the input will be integers.
- The values of , , , , , and will be between and , inclusive.
Small dataset(10 Pts)
Large dataset(17 Pts)