(简单) CF 44D Hyperdrive,数学。
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,数学。的更多相关文章
- CF Polycarpus' Dice (数学)
Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- CF 675 div2C 数学 让环所有值变为0的最少操作数
http://codeforces.com/contest/675/problem/C 题目大意: 给一个环,标号为1-n,然后能从n回到1.让这个环的值为0,最少需要的操作数是多少? 这道题目呀.. ...
- 牛客小白月赛1 B 简单题2 【数学】
题目链接 https://www.nowcoder.com/acm/contest/85/B 思路 这个 也是 E AC代码 #include <cstdio> #include < ...
- FZU 2125 简单的等式 【数学/枚举解方程式】
现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1. Inpu ...
- [CSP-S模拟测试]:简单的玄学(数学)
题目描述 有$m$个在$[0,2^n)$内均匀随机取值的整型变量,球至少有两个变量取值相同的概率.为了避免精度误差,假设你的答案可以表示成$\frac{a}{b}$的形式,(其中$(a,b)=1$), ...
- 股票中的数学:EMA的推导01
说明:本人并不炒股,原因很简单:没钱.当然了,作为一名IT工作者,因为工作需要和个人兴趣,就有了本系列文章.阅读本系列文章不需要任何高深的知识,哪怕是一个像我这样从未真正炒过股的人也没关系.但本文还是 ...
- CF 1025C Plasticine zebra
昨晚忘记判只有一个字符的情况fst了呜呜呜 挺有趣的题,昨晚连刚带猜弄出结论 考虑答案的取值,最优答案可能是一个后缀,或者是一个前缀,或者是一个后缀加上前缀 那么翻转之后最优答案的可选值就有了1的前缀 ...
- Python数学建模-02.数据导入
数据导入是所有数模编程的第一步,比你想象的更重要. 先要学会一种未必最佳,但是通用.安全.简单.好学的方法. 『Python 数学建模 @ Youcans』带你从数模小白成为国赛达人. 1. 数据导入 ...
- 【转载】ACM总结——dp专辑
感谢博主—— http://blog.csdn.net/cc_again?viewmode=list ---------- Accagain 2014年5月15日 动态规划一 ...
随机推荐
- 近十年one-to-one最短路算法研究整理【转】
前言:针对单源最短路算法,目前最经典的思路即标号算法,以Dijkstra算法和Bellman-Ford算法为根本演进了各种优化技术和算法.针对复杂网络,传统的优化思路是在数据结构和双向搜索上做文章,或 ...
- Entity Framework 学习中级篇4—存储过程(下)
在EF中,各个实体的插入.更新和删除也都通过使用存储过程来完成,以便提高点性能.这个类似于数据集.其步骤是:先定义存储过程,然后在VS的可视化设计器,设置存储过程映射即可. 下面,以为Supplier ...
- 关于IP在MySQL中的存储
对于很多新手而言,他们总会纠结,怎样才能更好的设计MySQL数据库呢:作为一个从菜鸟走过来的人,深有体会,刚开始我也不知道什么是外键.什么是事务处理.怎样合理的定义一个字段,说到字段,今天我就带领大家 ...
- lvs + keepalived + httpd 高可用集群(转)
实验信息和拓扑:备注:Centos 6.5 selinux –disabled iptables off ServerName Ipaddress information LVSMaster 172. ...
- mynotebook
www.linux.org/threads/beats-audio-on-linux.4443/ askubuntu.com/questions/303775/envy-15-beats-audio- ...
- sql server 数据库导出表里所有数据成insert 语句
有时候,我们想把数据库的某张表里的所有数据导入到另外一个数据库或另外一台计算机上的数据库,对于sql server有这样的一种方法 下面我以sql server 2008 R2,数据库是Northwi ...
- git 提交到github时不用每次都输入用户名,密码
Permanently authenticating with Git repositories, Run following command to enable credential caching ...
- 【纯欧拉函数】 poj 2407
#include <cstdio> #include <iostream> using namespace std; int phi(int x) { int t=x; ;i& ...
- OpenGL ES着色器语言之着色概览(官方文档)
OpenGL ES着色器语言之着色概览(官方文档第二章) 事实上,OpenGL ES着色语言是两种紧密关联的语言.这些语言用来在OpenGL ES处理管线的可编程处理器创建着色器. 在本文档中,除非另 ...
- java下载多个文件文件
第一步 将要下载的多个文件打包成ZIP格式 public String makeZip(List<String> path) throws IOException{ byte[] buff ...