CF 9B模拟
来源:互联网 发布:淘宝不能好评返现了 编辑:程序博客网 时间:2024/06/05 04:55
从(0,0)站点上车,要赶去(x,y)这个点,公交车只能沿着x轴开,问最快到x,y要从哪一下站下车…水题
#include<cstdio>#include<cmath>#include<cstring>#include<iostream>#include<algorithm>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;const double eps=1e-8;int sgn(double a){return a<-eps?-1:a<eps?0:1;}double dis(double x1,double y1,double x2){ return sqrt((x1-x2)*(x1-x2)+y1*y1);}int st[105];int main(){ int n,vb,vs,tx,ty; scanf("%d%d%d",&n,&vb,&vs); for(int i=0;i<n;i++) scanf("%d",&st[i]); scanf("%d%d",&tx,&ty); double ans=INF;int ansi=0; for(int i=1;i<n;i++) { double t=dis(1.0*tx,1.0*ty,1.0*st[i])/vs+1.0*st[i]/vb; if(sgn(t-ans)<=0) { ans=t; ansi=i; } } printf("%d\n",ansi+1);}
0 0
- CF 9B模拟
- cf 602 B(模拟)
- cf 697 B(模拟)
- CF 342B(Xenia and Spies-模拟)
- CF#274 (Div. 2) B.(暴力模拟)
- 某场CF B Octagons(模拟)
- cf 583 B. Robot's Task(模拟)
- cf#344-B - Print Check-暴力模拟
- cf 758 B. Blown Garland模拟
- cf -148 b double追赶问题模拟
- CF 868 B. Race Against Time【模拟】
- CF 9B Running Student
- [CF 239B][BNUOJ 26625] King's Path [模拟]
- CF#310-B - Case of Fake Numbers-模拟水题
- CF#322-B. Luxurious Houses-模拟水题
- cf#323-div2-B. Robot's Task-简单模拟
- CF#305-B. Mike and Fun-暴力模拟水题
- cf#339 -B. Gena's Code -模拟乘法
- extract(c1 from d1)
- dbtimezone
- current_timestamp
- 关于大神--->>>快速集成iOS基于RTMP的视频推流
- linux内核 策略路由之添加
- CF 9B模拟
- UVA 1252 Twenty Questions
- UVA 1627 Team them up!
- UVA 10934 Dropping water balloons
- 简单算法题之 Two Sum
- #ifdef #else #endif #fi #ifndef 的用法
- java IDEA加密/解密 源码
- POJ 3311 Hie with the Pie (Floyd + 暴力全排列 || Floyd + 状态压缩DP (已补充))
- linux内核 策略路由之查找