CF44D.Hyperdrive

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In a far away galaxy there are n inhabited planets, numbered with numbers from 1 to n. They are located at large distances from each other, that's why the communication between them was very difficult until on the planet number 1 a hyperdrive was invented. As soon as this significant event took place, n - 1 spaceships were built on the planet number 1, and those ships were sent to other planets to inform about the revolutionary invention.

Paradoxical thought it may be, but the hyperspace is represented as simple three-dimensional Euclidean space. The inhabited planets may be considered fixed points in it, and no two points coincide and no three points lie on the same straight line. The movement of a ship with a hyperdrive between two planets is performed along a straight line at the constant speed, the same for all the ships. That's why the distance in the hyperspace are measured in hyperyears (a ship with a hyperdrive covers a distance of s hyperyears in s years).

When the ship reaches an inhabited planet, the inhabitants of the planet dissemble it, make n - 2 identical to it ships with a hyperdrive and send them to other n - 2 planets (except for the one from which the ship arrived). The time to make a new ship compared to the time in which they move from one planet to another is so small that it can be disregarded. New ships are absolutely identical to the ones sent initially: they move at the same constant speed along a straight line trajectory and, having reached a planet, perform the very same mission, i.e. are dissembled to build new n - 2 ships and send them to all the planets except for the one from which the ship arrived. Thus, the process of spreading the important news around the galaxy continues.

However the hyperdrive creators hurried to spread the news about their invention so much that they didn't study completely what goes on when two ships collide in the hyperspace. If two moving ships find themselves at one point, they provoke an explosion of colossal power, leading to the destruction of the galaxy!

Your task is to find the time the galaxy will continue to exist from the moment of the ships' launch from the first planet.

在遥远的银河系中,有 nn 颗有人居住的行星,编号为 11nn。这些行星彼此相距极远,因此在第 11 号行星上发明超光速驱动器(hyperdrive)之前,它们之间的通信极为困难。这一重大事件发生后,立即在第 11 号行星上建造了 n1n-1 艘宇宙飞船,并将它们派往其余 n1n-1 颗行星,以宣告这项革命性发明。

尽管看似悖论,但超空间(hyperspace)被建模为普通的三维欧几里得空间。所有有人居住的行星可视为该空间中的固定点,且任意两点不重合,任意三点不共线。装备超光速驱动器的飞船在两颗行星之间运动时,沿直线以恒定速度航行,且所有飞船的速度均相同。因此,超空间中的距离单位为“超年”(hyperyear):一艘装备超光速驱动器的飞船在 ss 年内恰好航行 ss 超年的距离。

当一艘飞船抵达一颗有人居住的行星时,该行星的居民会将其拆解,并仿制出 n2n-2 艘完全相同的超光速飞船,然后将它们派往其余 n2n-2 颗行星(除飞船来向的那颗行星外)。制造一艘新飞船所需时间相比飞船在行星间航行所需时间极短,可忽略不计。新飞船与最初从第 11 号行星发射的飞船完全相同:它们同样沿直线以恒定速度航行;一旦抵达某颗行星,便执行完全相同的任务——即被拆解并用于制造 n2n-2 艘新飞船,再派往除来向行星外的所有其他行星。于是,这一传播重要消息的过程在整个银河系中持续进行。

然而,超光速驱动器的发明者急于传播其发明的消息,以至于未能充分研究两艘飞船在超空间中相撞时会发生什么。若两艘正在航行的飞船同时抵达同一点,便会引发一场威力空前的爆炸,导致整个银河系毁灭!

你的任务是:计算自第一颗行星发射飞船起,银河系还能存在多长时间。

输入格式

The first line contains a number n (3 ≤ n ≤ 5000) — the number of inhabited planets in the galaxy. The next n lines contain integer coordinates of the planets in format "x__i y__i z__i" ( - 104 ≤ x__i, y__i, z__i ≤ 104).

第一行包含一个整数 nn3n50003 \leq n \leq 5000)——表示银河系中有人居住的行星数量。接下来的 nn 行每行包含一个行星的整数坐标,格式为“xi yi zix_i\ y_i\ z_i”(其中 104xi, yi, zi104-10^4 \leq x_i,\ y_i,\ z_i \leq 10^4)。

输出格式

Print the single number — the solution to the task with an absolute or relative error not exceeding 10 - 6.

输出单个数字——该任务的解,其绝对或相对误差不超过 10610^{-6}

输入输出样例

  • 输入#1

    4
    0 0 0
    0 0 1
    0 1 0
    1 0 0

    输出#1

    1.7071067812

输入解题思路,AI测评打分。不知道怎么写?

首页