#9 (Div. 2 Only) B. Running Student (枚举)
来源:互联网 发布:linux移动文件夹覆盖 编辑:程序博客网 时间:2024/05/17 17:41
题目链接:
点击打开链接
http://codeforces.com/contest/9/problem/B
题意:给你车的速度,人跑步的速度,和站点的坐标,以及学校的坐标。问你从哪个站点下车可以最快到达学校?
题解:直接枚举下车的站点。
AC代码:
#include <bits/stdc++.h>using namespace std;double dis(double x1,double y1,double x2){return sqrt((x1-x2)*(x1-x2)+y1*y1);}int main(){int n;double vb,vs;cin>>n>>vb>>vs;vector<pair<int,int>>vp;int k;for(int i=0;i<n;i++){cin>>k;vp.push_back(make_pair(k,i));}double xu,yu;cin>>xu>>yu;double ans2 = dis(xu,yu,vp[1].first);ans2=ans2/vs+vp[1].first/vb;int ans=2;for(int i=2;i<n;i++){double tmp = dis(xu,yu,vp[i].first)/vs + vp[i].first / vb ;if(tmp <= ans2){ans2=tmp;ans=vp[i].second+1;}}cout<<ans<<endl;return 0;}
1 0
- #9 (Div. 2 Only) B. Running Student (枚举)
- 9B - Running Student
- CF 9B Running Student
- CodeForces 9B - Running Student
- CodeForces 9B Running Student
- Codeforces Beta Round #9 (Div. 2 Only):B
- CF 335 div.1-B/div.2-D/605 B Lazy Student
- CF 178(div 2)B(greedy + 枚举)
- AIM Tech Round 3 (Div. 2) -- B. Checkpoints (枚举)
- Codeforces Beta Round #86 (Div. 2 Only) B PFAST Inc.
- Codeforces Beta Round #93 (Div. 2 Only)——B
- Codeforces Beta Round #91 (Div. 2 Only)——B
- Codeforces Beta Round #18 (Div. 2 Only)——B
- Codeforces Beta Round #92 (Div. 2 Only) B. Permutations
- Codeforces Beta Round #22 (Div. 2 Only)-B. Bargaining Table
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) -- B. Batch Sort(暴力枚举)
- Codeforces Beta Round #9 (Div. 2 Only)
- 4. Running Student
- 自动建立swap分区脚本
- 使用cxf发布rest服务接口,和spring的整合
- maven上传私有jar包到本地私服仓库,私服使用nexus repository manager 3.3
- PAT1046
- 顺序表的简单实现--完整版
- #9 (Div. 2 Only) B. Running Student (枚举)
- C++模板
- PAT1056
- linux常用命令
- PAT1043
- 解决报错:One or more constraints have not been satisfied.
- Java Web项目开发项目经验总结
- [Hybris]DAO写法
- Android--使用反射修改TabLayout下划线宽度