首页 技术 正文
技术 2022年11月16日
0 收藏 508 点赞 5,094 浏览 2004 个字

B. Running Student

题目连接:

http://www.codeforces.com/contest/9/problem/B

Description

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.

Sample Input

4 5 2

0 2 4 6

4 1

Sample Output

3

Hint

题意

有一个小朋友,考试要迟到了,所以必须尽快的赶到学校。

他跑步的速度是v2,公交车的速度是v1,现在他可以选择从某一站下车,然后飞奔过去

现在问你应该从哪一站下车。

不允许从第一站下车啦,因为他就是从那儿上车的。

题解:

噜噜噜,水题啦,直接暴力枚举从哪儿下车就好了。

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int a[maxn];
double dis(double x1,double y1,double x2)
{
return sqrt((x1-x2)*(x1-x2)+y1*y1);
}
int main()
{
int n;
double v1,v2;
scanf("%d%lf%lf",&n,&v1,&v2);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
double x,y;cin>>x>>y;
double ans2 = dis(x,y,a[2])/v2+a[2]/v1;
int ans1 = 2;
for(int i=3;i<=n;i++)
{
double tmp = a[i]/v1+dis(x,y,a[i])/v2;
if(tmp<=ans2)ans2=tmp,ans1=i;
}
cout<<ans1<<endl;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918