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.

  很长的题目,然而并不难。。。

  题目就是从1发出N-1个火箭,然后到达一颗星之后那颗星再发出N-2颗,然后问第一次碰撞的时间。

  然后对于第一代火箭,也就是1发出的,一定不会碰撞,然后对于第二代火箭,一定不会和第一代碰撞,因为三角形两边之和大于第三边。

  但是第二代火箭会和第二代碰撞,所以枚举两个发出第二代火箭的点就好了。。。

代码如下:

// ━━━━━━神兽出没━━━━━━
// ┏┓ ┏┓
// ┏┛┻━━━━━━━┛┻┓
// ┃ ┃
// ┃ ━ ┃
// ████━████ ┃
// ┃ ┃
// ┃ ┻ ┃
// ┃ ┃
// ┗━┓ ┏━┛
// ┃ ┃
// ┃ ┃
// ┃ ┗━━━┓
// ┃ ┣┓
// ┃ ┏┛
// ┗┓┓┏━━━━━┳┓┏┛
// ┃┫┫ ┃┫┫
// ┗┻┛ ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━ // Author : WhyWhy
// Created Time : 2015年10月09日 星期五 21时51分18秒
// 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 namespace std; const int MaxN=; struct Point
{
double x,y,z;
}P[MaxN]; int N; double dist(const Point &a,const Point &b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout); double minn=1e100; scanf("%d",&N);
for(int i=;i<=N;++i)
scanf("%lf %lf %lf",&P[i].x,&P[i].y,&P[i].z);
for(int i=;i<=N;++i)
for(int j=i+;j<=N;++j)
minn=min(minn,dist(P[],P[i])+dist(P[],P[j])+dist(P[i],P[j]));
printf("%.10f\n",minn/2.0); return ;
}

(简单) CF 44D Hyperdrive,数学。的更多相关文章

  1. CF Polycarpus' Dice (数学)

    Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  2. CF 675 div2C 数学 让环所有值变为0的最少操作数

    http://codeforces.com/contest/675/problem/C 题目大意: 给一个环,标号为1-n,然后能从n回到1.让这个环的值为0,最少需要的操作数是多少? 这道题目呀.. ...

  3. 牛客小白月赛1 B 简单题2 【数学】

    题目链接 https://www.nowcoder.com/acm/contest/85/B 思路 这个 也是 E AC代码 #include <cstdio> #include < ...

  4. FZU 2125 简单的等式 【数学/枚举解方程式】

    现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1. Inpu ...

  5. [CSP-S模拟测试]:简单的玄学(数学)

    题目描述 有$m$个在$[0,2^n)$内均匀随机取值的整型变量,球至少有两个变量取值相同的概率.为了避免精度误差,假设你的答案可以表示成$\frac{a}{b}$的形式,(其中$(a,b)=1$), ...

  6. 股票中的数学:EMA的推导01

    说明:本人并不炒股,原因很简单:没钱.当然了,作为一名IT工作者,因为工作需要和个人兴趣,就有了本系列文章.阅读本系列文章不需要任何高深的知识,哪怕是一个像我这样从未真正炒过股的人也没关系.但本文还是 ...

  7. CF 1025C Plasticine zebra

    昨晚忘记判只有一个字符的情况fst了呜呜呜 挺有趣的题,昨晚连刚带猜弄出结论 考虑答案的取值,最优答案可能是一个后缀,或者是一个前缀,或者是一个后缀加上前缀 那么翻转之后最优答案的可选值就有了1的前缀 ...

  8. Python数学建模-02.数据导入

    数据导入是所有数模编程的第一步,比你想象的更重要. 先要学会一种未必最佳,但是通用.安全.简单.好学的方法. 『Python 数学建模 @ Youcans』带你从数模小白成为国赛达人. 1. 数据导入 ...

  9. 【转载】ACM总结——dp专辑

    感谢博主——      http://blog.csdn.net/cc_again?viewmode=list       ----------  Accagain  2014年5月15日 动态规划一 ...

随机推荐

  1. java基础概念经典题目汇集

    1.下面是People和Child类的定义和构造方法,每个构造方法都输出编号.在执行new Child("mike")的时候都有哪些构造方法被顺序调用?请选择输出结果 ( ) cl ...

  2. WPF Template模版之DataTemplate与ControlTemplate【一】

    WPF Template模版之DataTemplate与ControlTemplate[一] 标签: Wpf模版 2015-04-19 11:52 510人阅读 评论(0) 收藏 举报  分类: -- ...

  3. python3 与 python2的 区别比较

    http://sebug.net/paper/books/dive-into-python3/porting-code-to-python-3-with-2to3.html

  4. 取得GridView某行的DataKey

    首先绑定DataKeyNames GridView.DataKeyNames = new string[] { "字段名称" }; 取值 string aaa= GridView. ...

  5. iOS屏幕旋转 浅析

    一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...

  6. overflow:hidden

    超出之后隐藏,比如有一个div,高度和宽度都是100像素,当里面的内容很多,div里撑不下时,如果设置overflow:hidden,就会把超出的内容隐藏掉不显示

  7. 对于IE6版本图片透明。

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. 修改tomcat的get方法的参数长度

    在solr查询中,遇到查询字符串过长,返回错误,在tomcat的conf/server.xml中修改下面的参数即可.加上maxHttpHeaderSize="65536" < ...

  9. PHPstorm端口配置问题

  10. Tomcat的class加载的优先顺序

    Tomcat的class加载的优先顺序一览 1.最先是$JAVA_HOME/jre/lib/ext/下的jar文件. 2.环境变量CLASSPATH中的jar和class文件. 3.$CATALINA ...