Gym 100971F Two Points
来源:互联网 发布:linux 更改时区 编辑:程序博客网 时间:2024/05/18 17:05
题目链接
题意:给定两点,及它们各自的运功方向,求最小距离。
分析:初中数学。。。把直线参数方程求出,再套两点距离公式,二次函数求最值问题。
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int main(void){ int x1,y1,x2,y2; int v1x,v1y,v2x,v2y; while(scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&v1x,&v1y,&v2x,&v2y)==8) { double dx=x1-x2; double dy=y1-y2; double dvx=v1x-v2x; double dvy=v1y-v2y; double a=dvx*dvx+dvy*dvy; double b=dvx*dx+dvy*dy; double c=dx*dx+dy*dy; double t=b/a; if(a==0) { printf("%.15lf\n",sqrt(c)); continue; } if(t>=0) printf("%.15lf\n",sqrt(c)); else printf("%.15lf\n",sqrt(a*t*t-2*b*t+c)); } return 0;}
0 0
- Gym 100971F Two Points
- GYM 100971 F.Two Points(三分)
- GYM 100488 F.Two Envelopes(水~)
- [Gym-101350F] F
- Restore Points Gym
- Gym 100685 F Flood
- Gym 100989F STL
- codeforces Gym 101102F
- Codeforces-GYM-100726F
- Codeforces GYM 100803F
- Gym - 100947F
- [Gym-100520F]
- Gym 101142F Folding
- Gym 100553F-Filter
- Gym 101164.F
- Gym 101482.F
- Gym 101201.F
- hdu5200 Trees( two points)
- 前台和后台的数据交互
- Android 基本UI控件
- lightoj-1198 - Karate Competition【贪心】
- Visual Studio的相关插件安装:UE4.natvis和UnrealVS Extension
- C#控制台 类的实例化变量.tostring()什么作用
- Gym 100971F Two Points
- Python and or
- 南阳理工学院ACM语言入门题目1的思考
- 策略模式
- 死锁详解
- 部署tomcat方案时,出现红色叹号,并且显示file lock
- android打包时如何只生成单个apk而不需要obb
- Input Processing
- cts任务执行