#P13438. [GCJ 2009 #1C] Center of Mass

    ID: 15312 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>数学2009三分Special JudgeGoogle Code Jam

[GCJ 2009 #1C] Center of Mass

题目描述

You are studying a swarm of NN fireflies. Each firefly is moving in a straight line at a constant speed. You are standing at the center of the universe, at position (0,0,0)(0, 0, 0). 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 t=0t = 0, and are only interested in t0t \geq 0. The fireflies have constant velocity, and may pass freely through all of space, including each other and you. Let M(t)M(t) be the location of the center of mass of the NN fireflies at time tt. Let d(t)d(t) be the distance between your position and M(t)M(t) at time tt. Find the minimum value of d(t)d(t), dmind_{\text{min}}, and the earliest time when d(t)=dmind(t) = d_{\text{min}}, tmint_{\text{min}}.

输入格式

The first line of input contains a single integer TT, the number of test cases. Each test case starts with a line that contains an integer NN, the number of fireflies, followed by NN lines of the form

x y z vx vy vzx\ y\ z\ v_x\ v_y\ v_z

Each of these lines describes one firefly: (x,y,z)(x, y, z) is its initial position at time t=0t = 0, and (vx,vy,vz)(v_x, v_y, v_z) is its velocity.

输出格式

For each test case, output

Case #XX: dmind_{\text{min}} tmint_{\text{min}}

where XX is the test case number, starting from 1. Any answer with absolute or relative error of at most 10510^{-5} 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 NN points (xi,yi,zi)(x_i, y_i, z_i), their center of the mass is the point (xc,yc,zc)(x_c, y_c, z_c), where:

  • xc=(x1+x2++xN)/Nx_c = (x_1 + x_2 + \ldots + x_N) / N
  • yc=(y1+y2++yN)/Ny_c = (y_1 + y_2 + \ldots + y_N) / N
  • zc=(z1+z2++zN)/Nz_c = (z_1 + z_2 + \ldots + z_N) / N

Limits

  • All the numbers in the input will be integers.
  • 1T1001 \leq T \leq 100
  • The values of xx, yy, zz, vxv_x, vyv_y, and vzv_z will be between 5000-5000 and 50005000, inclusive.

Small dataset(10 Pts)

  • 3N103 \leq N \leq 10

Large dataset(17 Pts)

  • 3N5003 \leq N \leq 500