CodeForces 631C
2016-07-15 17:59
483 查看
设t时间最短,建方程,一元二次方程 ,分情况讨论最小值就行
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <queue> #include <cstdlib> #include <cstring> #include <vector> #include <set> using namespace std; #define ll long long #define maxn 9999999 #define eps 1e-6 int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int x1, y1, x2, y2; int vx1, vy1, vx2, vy2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); scanf("%d%d%d%d", &vx1, &vy1, &vx2, &vy2); ll a = 0, b = 0, c = 0; ll d1 = x1 - x2, d2 = y1 - y2, vd1 = vx1 - vx2, vd2 = vy1 - vy2; a = vd1*vd1 + vd2*vd2; b = 2 * d1*vd1 + 2 * d2*vd2; c = d1*d1 + d2*d2; double ans = 0; if (a == 0) { ans = sqrt(c); } else { //ll xx = b*b - 4 * a*c; double minx = -(b*1.0 / (2.0*a)); if (abs(minx - 0) < eps || minx < 0) { ans = sqrt(c); } else { ans = sqrt(a*minx*minx + b*minx + c); } } printf("%.10f\n", ans); //system("pause"); //while (1); return 0; }
相关文章推荐
- vim 查看函数列表
- **PHP** 表单(2)-表单完成
- Java Web学习(17):JSP动作元素(二)
- sublime text 文件打开时回调一些函数
- 请教<context:component-scan/>和<mvc:annotation-driven/>的区别20
- UVALive 6887 Book Club 最大流解最大匹配
- 适用于UWP应用开发的开源React Native插件
- 线段树刷题指南(转载自网络)
- HDU 5335 BFS
- Django UnicodeEncodeError解决
- HDU 4499 DFS
- IOS开发广告接入iAD框架_InMobi框架
- 六大Web负载均衡原理与实现
- set问题
- CodeForces Gym 100114C 打表
- 判断字符串是否为空
- Umbraco 官方技术文档 翻译 四 、Creating media-创建媒体
- 人件
- 对比git rm和rm的使用区别
- java基础——了解Enum