4. Running Student
来源:互联网 发布:数据整合平台 编辑:程序博客网 时间:2024/05/16 07:21
- Running Student
time limit per test: 1 seconds memory limit per test: 64 megabytes
And again a misfortune fell on Poor Student. He is being late for an exam.
Having rushed to a bus stop that is in point (0,0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.
Poor Student knows the following:
during one run the minibus makes n stops, the i-th stop is in point (xi,0)
coordinates of all the stops are different
the minibus drives at a constant speed, equal to vb
it can be assumed the passengers get on and off the minibus at a bus stop momentarily
Student can get off the minibus only at a bus stop
Student will have to get off the minibus at a terminal stop, if he does not get off earlier
the University, where the exam will be held, is in point (xu,yu)
Student can run from a bus stop to the University at a constant speed vs as long as needed
a distance between two points can be calculated according to the following formula:
Student is already on the minibus, so, he cannot get off at the first bus stop
Poor Student wants to get to the University as soon as possible. Help him to choose the bus stop, where he should get off. If such bus stops are multiple, choose the bus stop closest to the University.
Input
The first line contains three integer numbers: 2≤n≤100, 1≤vb,vs≤1000. The second line contains n non-negative integers in ascending order: coordinates xi of the bus stop with index i. It is guaranteed that x1 equals to zero, and xn≤105. The third line contains the coordinates of the University, integers xu and yu, not exceeding 105 in absolute value.
Output
In the only line output the answer to the problem − index of the optimum bus stop.
Examples
Input
4 5 2
0 2 4 6
4 1
Output
3
Input
2 1 1
0 100000
100000 100000
Output
2
Note
As you know, students are a special sort of people, and minibuses usually do not hurry. That’s why you should not be surprised, if Student’s speed is higher than the speed of the minibus.
#include<iostream>#include<cmath>using namespace std;int n;double vb,vs,x[1005],xu,yu;double minans=1<<29,minlength=1<<29;int mini=0;int main(){ cin>>n>>vb>>vs; for (int i=1;i<=n;i++) { cin>>x[i]; } cin>>xu>>yu; for (int i=2;i<=n;i++) { double length=(x[i]-xu)*(x[i]-xu)+yu*yu; double temp=x[i]/vb+sqrt(length/(vs*vs)); if (temp<minans) { minans=temp; minlength=length; mini=i; } else if (temp==minans&&length<minlength) { minans=temp; minlength=length; mini=i; } } cout<<mini; return 0;}
- 4. Running Student
- 9B - Running Student
- CF 9B Running Student
- CodeForces 9B - Running Student
- CodeForces 9B Running Student
- #9 (Div. 2 Only) B. Running Student (枚举)
- student
- student
- student
- student
- student
- running
- Student.java
- student.class
- csdn student
- student 类库
- student.sql
- Headstrong Student
- 【个人笔记】WAMP httpd.conf的配置修改使其它IP可访问
- 封装复制文件函数
- The 2016 ACM-ICPC Asia Tehran Regional Contest 部分题解!
- java底层知识
- Linux中DHCP服务器配置
- 4. Running Student
- Office远程代码执行漏洞POC样本分析(CVE-2017-11882)
- 11 H5上实现超声波测距模块的设备驱动
- STL里面的next_permutation求字典序排列问题
- 《时代》17年十大电子设备:iPhone X登榜
- leetcode解题方案--034--Search for a Range
- 关于Hibernate中的级联操作以及懒加载
- Windows 7 下 安装 mysql-5.7.20-win32.zip 教程
- 进程和线程