Simple CF 44D hyperdrive, mathematics.

Source: Internet
Author: User
Tags emit

In a far away galaxy there is N inhabited planets, numbered with numbers from 1 to n. They is located at large distances from all other, that's why the communication between them is 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 tho SE ships were sent to other planets to inform about the revolutionary invention.

Paradoxical thought it may, but the hyperspace was represented as simple three-dimensional Euclidean space. The inhabited planets may is considered fixed points in it, and no to the points coincide and no three points lie on the same Straight line. The movement of a ship with a hyperdrive between-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 is measured in hyperyears (a ship with a hyperdrive covers a distance of < Span class= "Tex-span" > 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 do a new ship compared to the time in which they move from one planet to another are so small the It can disregarded. New ships is absolutely identical to the ones sent Initially:they move on the same constant speed along a straight line Trajectory and, having reached a planet, perform the very same mission, i.e. is 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 on their invention so much that they didn ' t study completely What goes on when the ships collide in the hyperspace. If moving ships find themselves at one point, they provoke a explosion of colossal power, leading to the destruction of the galaxy!

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

It's a long question, but it's not hard ...

The problem is to send a N-1 rocket from 1, then arrive at a star and the star will emit N-2, then ask the time of the first collision.

Then for the first generation of rockets, that is 1 issued, will not collide, and then for the second generation of rockets, will not collide with the first generation, because the triangle on both sides of the sum greater than the third side.

But the second generation of rockets will collide with the second generation, so it's good to enumerate two points that emit a second-generation rocket ...

The code is as follows:

//The ━━━━━━ of gods and Beasts ━━━━━━//┏┓┏┓//┏┛┻━━━━━━━┛┻┓//┃┃//┃━┃//████━████┃//┃┃//┃┻┃//┃┃//┗━┓┏━┛//┃┃//┃┃//┃┗━━━┓//┃┣┓//┃┏┛//┗┓┓┏━━━━━┳┓┏┛//┃┫┫┃┫┫//┗┻┛┗┻┛////━━━━━━ Feel the ━━━━━━ of Meng Meng//author:whywhy//Created time:2015 October 09 Friday 21:51 18 seconds//File name:a.cpp#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<stdlib.h>#include<time.h>using namespacestd;Const intmaxn=5005;structpoint{Doublex, Y, Z;} P[MAXN];intN;DoubleDistConstPoint &a,ConstPoint &b) {    returnsqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y) + (a.z-b.z) * (a.z-b.z));}intMain () {//freopen ("In.txt", "R", stdin); //freopen ("OUT.txt", "w", stdout);    Doubleminn=1e100; scanf ("%d",&N);  for(intI=1; i<=n;++i) scanf ("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);  for(intI=2; i<=n;++i) for(intj=i+1; j<=n;++j) Minn=min (Minn,dist (p[1],p[i]) +dist (p[1],P[J]) +Dist (p[i],p[j])); printf ("%.10f\n", minn/2.0); return 0;}
View Code

Simple CF 44D hyperdrive, mathematics.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.