codeforces GYM 100971F 公式题或者三分
2 seconds
256 megabytes
standard input
standard output
There are two points (x1, y1) and (x2, y2) on the plane. They move with the velocities (vx1, vy1) and (vx2, vy2). Find the minimal distance between them ever in future.
The first line contains four space-separated integers x1, y1, x2, y2 ( - 104 ≤ x1, y1, x2, y2 ≤ 104) — the coordinates of the points.
The second line contains four space-separated integers vx1, vy1, vx2, vy2 ( - 104 ≤ vx1, vy1, vx2, vy2 ≤ 104) — the velocities of the points.
Output a real number d — the minimal distance between the points. Absolute or relative error of the answer should be less than 10 - 6.
1 1 2 2
0 0 -1 0
1.000000000000000
1 1 2 2
0 0 1 0
1.414213562373095
题意:给你两个点的位置与x轴方向的速度,y轴方向的速度,求两个点最近的距离;
思路:根据题意:得到两个相差x的距离的平方+y轴相差距离的平方得到一元二次方程;
利用公式得到最小值;
#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 100000007
#define esp 0.00000000001
const int N=2e5+,M=1e6+,inf=1e9;
int main()
{
double x,y,a,b,z,i,t;
double vx,vy,va,vb;
cin>>x>>y>>a>>b;
cin>>vx>>vy>>va>>vb;
double fa,fb,fc;
fa=(vx-va)*(vx-va)+(vy-vb)*(vy-vb);
fb=2.0*((vb-vy)*(b-y)+(va-vx)*(a-x));
fc=(a-x)*(a-x)+(b-y)*(b-y);
double ans=(*fa*fc-fb*fb)/(*fa);
double zuo=-fb/(2.0*fa);
if(zuo>=0.0)
printf("%.6f\n",sqrt(ans));
else
printf("%.6f\n",sqrt(fc));
return ;
}
codeforces GYM 100971F 公式题或者三分的更多相关文章
- codeforces Gym 100735 D、E、G、H、I
http://codeforces.com/gym/100735 D题 直接暴力枚举 感觉这道题数据有点问题 为什么要先排下序才能过?不懂.. #include <stdio.h> #in ...
- Codeforces Gym 101252D&&floyd判圈算法学习笔记
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...
- Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】
2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...
- Codeforces C. Elections(贪心枚举三分)
题目描述: C. Elections time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Gym 100338C C - Important Roads tarjan
C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contes ...
- Codeforces Gym 101190M Mole Tunnels - 费用流
题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...
- Codeforces Gym 101623A - 动态规划
题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...
- 【Codeforces Gym 100725K】Key Insertion
Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K, ...
- codeforces gym 100553I
codeforces gym 100553I solution 令a[i]表示位置i的船的编号 研究可以发现,应是从中间开始,往两边跳.... 于是就是一个点往两边的最长下降子序列之和减一 魔改树状数 ...
随机推荐
- Ubentu下安装Docker
具体可以查看Docker官网,我是在服务器上面操作 1,sudo apt-get install -y apt-transport-https ca-certificates curl softwar ...
- 《闪存问题之READ DISTURB》总结
来自 http://www.ssdfans.com/?p=1778 闪存存在几个问题,影响着数据可靠性: 1.擦除次数,闪存擦除次数增多,会使隔离栅极的电化学键变弱. 2.data retention ...
- Charles 抓包工具的使用
抓包工具有很多,目前用过的有Charles, Fiddler, burpsuite.下面主要是Charles 的应用实例. 一. 用Charles抓包 1. PC 抓包 打开Charles, 确保“录 ...
- 项目总结之HashMap问题
在项目中我需要用另一个项目的中的方法,在另一个项目中的方法返回值是一个hashmap,返回的不是一个hashMap中存的对象而是Object对象.在一个项目中调用另一个项目中的方式是直接引入另一个项目 ...
- zabbix 4.0 安装配置
1.安装软件包: 1.安装软件包: yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap ...
- Oracle 分组函数
分组函数的介绍 分组函数作用于一组数据,并对一组数据返回一个值. (引用网上的一张图) 分组函数的使用规则 SELECT [column,] group_function(column) FROM t ...
- 【转】阿里巴巴技术专家杨晓明:基于Hadoop技术进行地理空间分析
转自:http://www.csdn.net/article/2015-01-23/2823687-geographic-space-base-Hadoop [编者按]交通领域正产生着海量的车辆位置点 ...
- ubuntu中mysql版本升级到5.7
0 前言 前几天图书馆说服务器(Ubuntu14.04)有安全漏洞,不按时修复会关停. 看了一下漏洞清单,主要是ssh和mysql的版本问题. 把mysql升级了一下,升到了5.7,升级之前还备份了数 ...
- Eclipse+Spark搭建源码分析环境问题分析
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- Linux 实时性能测试工具——Cyclictest
Cyclictest 是 rt-tests 下的一个测试工具,也是rt-tests 下使用最广泛的测试工具,一般主要用来测试使用内核的延迟,从而判断内核的实时性. 1.2 cyclictest 安装 ...