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. 前端黑客之XSS、CSRF

    XSS:跨站脚本,发生在目标网站中目标用户的浏览器层面上,当用户浏览器渲染整个HTML文档的过程中出现了不被预期的脚本指令并执行时,XSS就会发生. 绝大多数XSS攻击都会采用嵌入一段远程或者第三方域 ...

  2. R中seurat等问题学习

    1.Seurat 转自:https://cloud.tencent.com/developer/article/1055892 # Initialize the Seurat object with ...

  3. flyweight模式

    参考资料 • 维基百科:https://en.wikipedia.org/wiki/Flyweight_pattern • 百度百科:http://baike.baidu.com/link?url=R ...

  4. Junit 并行执行测试

    从Junit4.7开始可以并行运行测试. 必须设置parallel 参数,可以改变threadCount或useUnlimitedThreads属性. 测试中指定了parallel,项目使用的是 JU ...

  5. 如何设计Spring读取某种文件的逻辑顺序

    1. 判断系统属性System.getProperty("apdb.config.path", "");,有的话,优先使用.(系统属性可以在命令行中以 -D&l ...

  6. inline-block布局错位问题

    如图, 两个display为 inline-block的元素,会出现情况 针对第三种情况: 需要添加 vertical-align: top; 参考代码 <!DOCTYPE html> & ...

  7. PHP计算上一个月最后一天、当月最后一天、下一个月最后一天

    上个月最后一天: $last_month_last_day = date('Y-m-t',strtotime('-1 month')); 当月最后一天: $first_day=date('Y-m-01 ...

  8. Python中i = i + 1与i + = 1的区别

    +=是对原本的实例做加1运算,l=l+[1]是对l+[1]之后重新把值赋给叫l的变量(和原来的l不同) 区别在于,一个修改数据结构本身(就地操作)b + = 1而另一个只是重新分配变量a = a + ...

  9. XDU 1032

    #include<cstdio> typedef long long ll; ; ll feima(ll a,ll b) { ll c=; while(b) { ) c=c*a%mod; ...

  10. 2017 Multi-University Training Contest - Team 4 hdu6071 Lazy Running

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6071 题目: Lazy Running Time Limit: 2000/1000 MS (J ...