Codeforces Beta Round #9 (Div. 2 Only) B. Running Student 水题
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 水题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
随机推荐
- 按键精灵MySql数据库操作
查询 MySql服务器地址="192.168.1.166" 用户名 = "root" 密码 = " 数据库名="bookshop" ...
- Mysql储存过程5: while
循环结构 while create procedure name() begin while 条件 do SQL语句 end while; end$ create procedure aa6() be ...
- CentOS测网速
当发现上网速度变慢时,人们通常会先首先测试自己的电脑到网络服务提供商(通常被称为"最后一公里")的网络连接速度.在可用于测试宽带速度的网站中,Speedtest.net也许是使用最 ...
- python tornado 中使用 flash消息闪现
1.html 中引入文件 {% block head %} <link href="/static/common/sweetalert/sweetalert.css" rel ...
- php+mysql缓存技术的实现
本教程适合于那些对缓存SQL查询以减少数据库连接与执行的负载.提高脚本性能感兴趣的PHP程序员.概述 许多站点使用数据库作为站点数据存储的容器.数据库包含了产器信息.目录结构.文章或者留言本,有些数据 ...
- VS里属性窗口中的生成操作释义
生成操作:无,编译 ,内容 ,嵌入的资源... 如果是类.cs文件,就得编译之后你才能使用的.如果是txt,excel 这种文件,就属性内容或者资源文件了. 内容(Content) - 不编译该文件, ...
- asp基础
0.1在浏览器中通过查看源代码的方式是无法看到 ASP 源代码的,你只能看到由 ASP 文件输出的结果,而那些只是纯粹的 HTML 而已.这是因为,在结果被送回浏览器前,脚本已经在服务器上执行了. 0 ...
- MINI_httpd移植,构建小型WEB服务器
一.简介 目的:构建小型WEB站,具备SSL. mini_httpd is a small HTTP server. Its performance is not great, but for low ...
- Linux 用户篇——用户管理命令之useradd、passwd、userdel、usermod
一.用户重要,用户管理命令同样重要 用户是Linux系统安全的核心,每个登录Linux系统的用户都会分配相应的权限,这些权限取决于能否访问系统中各种对象.而管理这些用户的相关信息离不开用户管理命令,比 ...
- 【转】Android打印机--没有设备驱动sdk,自己实现USB打印功能
原文:http://blog.csdn.net/johnwcheung/article/details/71576833 Android下的设备调试,如果设备提供了驱动,按照厂家的驱动调试即可:设备未 ...