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;
}

Codeforces Beta Round #9 (Div. 2 Only) B. Running Student 水题的更多相关文章

  1. Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll 水题

    A. Die Roll 题目连接: http://www.codeforces.com/contest/9/problem/A Description Yakko, Wakko and Dot, wo ...

  2. Codeforces Beta Round #5 A. Chat Server's Outgoing Traffic 水题

    A. Chat Server's Outgoing Traffic 题目连接: http://www.codeforces.com/contest/5/problem/A Description Po ...

  3. Codeforces Beta Round #3 A. Shortest path of the king 水题

    A. Shortest path of the king 题目连接: http://www.codeforces.com/contest/3/problem/A Description The kin ...

  4. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  5. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  6. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  7. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  9. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

随机推荐

  1. [转载]PM管理技巧

      产品经理的沟通策略 2016年10月11日/分类: 文章 /编辑: Amy 产品经理处于沟通枢纽的位置,工作中需要跟各种岗位的人打交道,比如:领导.开发.运营.客户.用户.合作伙伴… 沟通能力是产 ...

  2. defer用途

    package main /* defer :程序退出时执行,先进后执行 defer庸碌: 1.关闭文件句柄 2.锁资源释放 3.数据库连接释放 */ import ( "fmt" ...

  3. 日常开发技巧:x11-forward,使用远程机器的gui程序

    背景 日常用过ssh登录服务器进行工作,尽管大部分时间,都只需要终端操作,编辑源码也是vim就够用了. 但有时候,还是需要使用gui程序的,比如打开一份pdf,word,ppt,excel等. 碰到这 ...

  4. SQLite3 C/C++ 开发接口简介(API函数)

    from : http://www.sqlite.com.cn/MySqlite/5/251.Html 1.0 总览 SQLite3是SQLite一个全新的版本,它虽然是在SQLite 2.8.13的 ...

  5. ProxySQL(MGR)部署故障:'sys.gr_member_routing_candidate_status' doesn't exist

    ProxySQL(MGR) 故障排查: 故障现象:runtime_mysql_servers节点状态offline_hostgroup(本案例为15) 日志关键信息: [WARNING] Group ...

  6. groovy的三个强劲属性(一)Gpath

            我们先从GPath开始,一个GPath是groovy代码的一个强劲对象导航的结构,名称的选择与XPath相似,XPath是一个用来描述XML(和等价物)文档的标准,正如XPath,GP ...

  7. ECharts图表tooltip显示时超出canvas图层解决方法

    我们在做ECharts图表的时候可能会遇到tooltip显示时超出了canvas图层范围,并且被其它z-index较高的div容器遮盖,这是悬浮展示信息就看不全,我们根据官网文档的配置项查询发现con ...

  8. ios测试apk

    最近apk在ios上面测试总是会遇到奇奇怪怪的问题,现在是两个项目要集成在一个apk中所以将两个项目运行之后都是编译成了.a文件,然后在两个.a文件中都设置了两个意义相同变量名相同的全局变量(标识当前 ...

  9. TCP封包解包---如有错误,请纠正!

    最近遇见很多的关于TCP中封包解包的数据,在TCP节点之间的信息传递,每次传送的内容是结构体,所以每次在传送的时候,要将结构体中的数据进行封包,然后当一端接收到数据之后,要对接收到的buf参数中的数据 ...

  10. 【转】【delphi】ClientDataSet详细解读

    原文:http://www.cnblogs.com/lcw/p/3496764.html TClientDataSet的基本属性和方法 TClientDataSet控件继承自TDataSet,其数据存 ...