二分 Codeforces591D Chip 'n Dale Rescue Rangers

阅读: 评论:0

二分 Codeforces591D Chip 'n Dale Rescue Rangers

二分 Codeforces591D Chip 'n Dale Rescue Rangers

传送门:点击打开链接

题意:前t秒,风速的向量为(vx,vy),t秒后风速的向量变成(wx,wy),刚开始在(x1,y1),要去(x2,y2),飞机速度的最大大小是v,问到达目的地至少需要多长的时间

思路:二分时间,那么就能求出风速对飞机位移的影响,那么影响后,现在与目的地的距离求出来,让飞机直行看是否能在时间内到达,就算验证二分是否满足条件了,剩下的二分就行。

#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck(x) cout<<"["<<x<<"]"
#define FIN freopen(&#","r",stdin)
#define FOUT freopen(&#","w+",stdout)
using namespace std;
typedef long long LL;int main() {double x1, y1, x2, y2; //FIN;double v, t, vx, vy, wx, wy;while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &v, &t, &vx, &vy, &wx, &wy)) {double l = 0, r = 1e9, m;for(int i = 1; i <= 100; i++) {m = (l + r) / 2;double x = x1 + vx * min(m, t) + wx * max(m - t, 0.0);double y = y1 + vy * min(m, t) + wy * max(m - t, 0.0);double dist = sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));if(dist <= v * m) r = m;else l = m;}printf("%.10lfn", l);}return 0;
}


本文发布于:2024-01-31 18:47:24,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170669804730599.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:Chip   Codeforces591D   Dale   Rangers   Rescue
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23