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. Perl6多线程4: Promise allof / anyof

    allof   : 所有代码块执行完成后才退出 anyof :只要有一个代码块执行完后就马上退出 要配合 await 一起用: my $p = start {say 'a'}; ;say 'b';} ...

  2. 使用正则表达式匹配IP地址

    IP地址分为4段,以点号分隔.要对IP地址进行匹配,首先要对其进行分析,分成如下部分,分别进行匹配:   第一步:地址分析,正则初判 1.0-9 \d 进行匹配 2.10-99 [1-9]\d 进行匹 ...

  3. [ python ] 线程的操作

    目录 (见右侧目录栏导航) - 1. 前言    - 1.1 进程    - 1.2 有了进程为什么要有线程    - 1.3 线程的出现    - 1.4 进程和线程的关系    - 1.5 线程的 ...

  4. IntelliJ IDEA 创建maven项目一次后,然后删除,再次保存到此目录下,提供此目录已经被占用的问题。

    -------------------2017-02-14补充: 你看既然是创建过一次 不允许再次创建了,那么请问 第一次创建的 跑哪里去了,不仅仅是保存到了你指定的目录里,其实也默认安装到了 mav ...

  5. 20165301 2017-2018-2 《Java程序设计》第五周学习总结

    20165301 2017-2018-2 <Java程序设计>第五周学习总结 教材学习内容总结 第七章:内部类与异常类 内部类 在一个类中定义另一个类 非内部类不可以是static类 匿名 ...

  6. xcode上真机调试iphone4s出现“There was an internal API error.”解决方案

    xcode7更新之后使用真机调试,在IOS8的一台Iphone5手机上面没什么问题,IOS8的一台iphone6也没问题.但是在IOS6的一台Iphone4s和 IOS7的ipad air2上面在最后 ...

  7. 洛谷 P1652圆 题解

    题目传送门 这道题也就是考你对几何的了解: 圆与圆没有公共点且一个圆在另一个圆外面时,叫做圆与圆相离. 当圆心距大于两圆半径之和时,称为两圆外离: 当圆心距小于两圆半径之差的绝对值时,称为两圆内含. ...

  8. 美团offer面经

    美团offer面经 2017北京美团金融服务平台,java后台研发方向,一共3面技术面+HR面,前两轮技术面在酒店面的,第三面和HR面在总部. 一面(重复问的部分就写一次了)(40分钟) 1.自我介绍 ...

  9. 《java虚拟机》----垃圾收集、内存分配

    No1: 程序计数器.虚拟机栈.本地方法栈3个区域随线程而生,随线程而灭:栈中的栈帧随着方法的进入和退出而有条不紊的执行着出栈和入栈操作.每一个栈帧中分配多少内存基本上市在类结构确定下来时就已知的,因 ...

  10. 项目中jquery插件ztree使用记录

    最近公司要求做一个关于后台的管理系统.在这个mvvm模式横行的年代,虽然这里用jquery做项目可能有点不符合时代的潮流,但是管他呢,能做出来先在说呗(公司以后要改用angular或者vue来统一前端 ...