QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 27

#5798. 质心

统计

你正在研究一群由 $N$ 只萤火虫组成的群体。每只萤火虫都在以恒定的速度沿直线运动。你站在宇宙的中心,即位置 $(0, 0, 0)$ 处。每只萤火虫的质量相同,你想知道萤火虫群的质心距离你的位置(原点)最近能达到多少。

已知每只萤火虫在 $t = 0$ 时的位置和速度,且你只对 $t \ge 0$ 的情况感兴趣。萤火虫的速度恒定,并且可以在空间中自由穿行,包括穿过彼此以及穿过你。设 $M(t)$ 为 $N$ 只萤火虫在时刻 $t$ 的质心位置。设 $d(t)$ 为在时刻 $t$ 时你的位置与 $M(t)$ 之间的距离。求 $d(t)$ 的最小值 $d_{\min}$,以及达到 $d(t) = d_{\min}$ 的最早时刻 $t_{\min}$。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。每个测试用例的第一行包含一个整数 $N$,表示萤火虫的数量,随后是 $N$ 行,每行格式如下:

x y z vx vy vz

每一行描述一只萤火虫:$(x, y, z)$ 是其在 $t = 0$ 时的初始位置,$(vx, vy, vz)$ 是其速度。

输出格式

对于每个测试用例,输出:

Case #X: dmin tmin

其中 $X$ 是测试用例编号,从 1 开始。任何绝对误差或相对误差不超过 $10^{-5}$ 的答案都将被接受。

数据范围

所有输入数值均为整数。

$1 \le T \le 100$

$x, y, z, vx, vy, vz$ 的取值范围在 $-5000$ 到 $5000$ 之间(含边界)。

子任务

小型数据集(10 分): $3 \le N \le 10$

大型数据集(17 分): $3 \le N \le 500$

样例

样例输入 1

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

样例输出 1

Case #1: 0.00000000 1.00000000
Case #2: 1.00000000 6.00000000
Case #3: 3.36340601 1.00000000

说明

给定 $N$ 个点 $(x_i, y_i, z_i)$,它们的质心是点 $(x_c, y_c, z_c)$,其中:

xc = (x1 + x2 + ... + xN) / N
yc = (y1 + y2 + ... + yN) / N
zc = (z1 + z2 + ... + zN) / N

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.