F. Two Points
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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

Output a real number d — the minimal distance between the points. Absolute or relative error of the answer should be less than 10 - 6.

Examples
input
1 1 2 2
0 0 -1 0
output
1.000000000000000
input
1 1 2 2
0 0 1 0
output
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 公式题或者三分的更多相关文章

  1. codeforces Gym 100735 D、E、G、H、I

    http://codeforces.com/gym/100735 D题 直接暴力枚举 感觉这道题数据有点问题 为什么要先排下序才能过?不懂.. #include <stdio.h> #in ...

  2. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  3. 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 ...

  4. Codeforces C. Elections(贪心枚举三分)

    题目描述: C. Elections time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Gym 100338C C - Important Roads tarjan

    C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contes ...

  6. Codeforces Gym 101190M Mole Tunnels - 费用流

    题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...

  7. Codeforces Gym 101623A - 动态规划

    题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...

  8. 【Codeforces Gym 100725K】Key Insertion

    Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K, ...

  9. codeforces gym 100553I

    codeforces gym 100553I solution 令a[i]表示位置i的船的编号 研究可以发现,应是从中间开始,往两边跳.... 于是就是一个点往两边的最长下降子序列之和减一 魔改树状数 ...

随机推荐

  1. django中使用redis

    第一种 安装redis模块 1.1在app中定义一个redis的连接池的py文件 import redis POOL=redis.ConnectionPool(host='127.0.0.1',por ...

  2. django组件之ContentType

    ContentTyep组件: 帮助我们关联所有数据库的表 帮助我们反向查询关联数据表中的所有策略信息 GenericForeignkey(帮助我们快速插入数据) GenericRelation(用于反 ...

  3. git学习------>如何修改git已提交的记录中的Author和Email?

    一.背景 最近搭建好GitLab后,准备陆陆续续的将之前在SVN仓库中保存的代码迁移到GitLab上,昨天顺利将三个Android组件的代码迁移到GitLab后,其他同事发现迁移是成功了,但是pull ...

  4. windows脚本-CMD和Batch

    一.DOS,CMD和batch DOS是磁盘操作系统(英文:Disk Operating System)的缩写,是个人计算机上的一类操作系统.从1981年直到1995年的15年间,DOS在IBM PC ...

  5. Linux:Centos7升级内核(转)

    更新前,内核版本为: uname -r 3.10.0-327.10.1.el7.x86_64 升级的方法: 1.导入key rpm --import https://www.elrepo.org/RP ...

  6. 学习Zookeeper需要了解的专业名词

    一.Zookeeper的集群角色 Leader:该角色是整个zookeeper集群工作机制中的核心 Follower:该角色是zookeeper集群状态的跟随者 Observer:在集群中充当观察者的 ...

  7. .net:Code First 创建或更新数据库

    控制台输入命令: 切换到项目的project.json 文件所在文件 dotnet ef migrations add XXX dotnet ef database update Visual Stu ...

  8. HDU 1142 A Walk Through the Forest(Dijkstra+记忆化搜索)

    题意:看样子很多人都把这题目看错了,以为是求最短路的条数.真正的意思是:假设 A和B 是相连的,当前在 A 处, 如果 A 到终点的最短距离大于 B 到终点的最短距离,则可以从 A 通往 B 处,问满 ...

  9. HDU - 4871 Shortest-path tree (最短路径树+ 树分治)

    题意:给你一张带权无向图,先求出这张图从点1出发的最短路树,再求在树上经过k个节点最长的路径值,以及个数. 分析:首先求最短路树,跑一遍最短路之后dfs一遍即可建出最短路树. 第二个问题,树分治解决. ...

  10. C++文件路径的写法

    转自:http://blog.csdn.net/chengonghao/article/details/51057780 文件路径的表示可以分为绝对路径和相对路径: c++中\\是一种转义字符,他表示 ...