D. Max and Bike
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/595/problem/D
Description
For months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cyclists' competitions.
He knows that this year n competitions will take place. During the i-th competition the participant must as quickly as possible complete a ride along a straight line from point si to point fi (si < fi).
Measuring time is a complex process related to usage of a special sensor and a time counter. Think of the front wheel of a bicycle as a circle of radius r. Let's neglect the thickness of a tire, the size of the sensor, and all physical effects. The sensor is placed on the rim of the wheel, that is, on some fixed point on a circle of radius r. After that the counter moves just like the chosen point of the circle, i.e. moves forward and rotates around the center of the circle.
At the beginning each participant can choose any point bi, such that his bike is fully behind the starting line, that is, bi < si - r. After that, he starts the movement, instantly accelerates to his maximum speed and at time tsi, when the coordinate of the sensor is equal to the coordinate of the start, the time counter starts. The cyclist makes a complete ride, moving with his maximum speed and at the moment the sensor's coordinate is equal to the coordinate of the finish (moment of time tfi), the time counter deactivates and records the final time. Thus, the counter records that the participant made a complete ride in time tfi - tsi.
Maxim is good at math and he suspects that the total result doesn't only depend on his maximum speed v, but also on his choice of the initial point bi. Now Maxim is asking you to calculate for each of n competitions the minimum possible time that can be measured by the time counter. The radius of the wheel of his bike is equal to r.
⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.
⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?
Input
The first line contains three integers n, r and v (1 ≤ n ≤ 100 000, 1 ≤ r, v ≤ 109) — the number of competitions, the radius of the front wheel of Max's bike and his maximum speed, respectively.
Next n lines contain the descriptions of the contests. The i-th line contains two integers si and fi (1 ≤ si < fi ≤ 109) — the coordinate of the start and the coordinate of the finish on the i-th competition.
Output
Print n real numbers, the i-th number should be equal to the minimum possible time measured by the time counter. Your answer will be considered correct if its absolute or relative error will not exceed 10 - 6.
Namely: let's assume that your answer equals a, and the answer of the jury is b. The checker program will consider your answer correct if .
Sample Input
2 1 2
1 10
5 9
Sample Output
3.849644710502
1.106060157705
HINT
题意
有一个*,*上的一点,要从f滚到s
你可以随意选择一开始*的点在哪儿
然后问你最少多少时间
题解:
我们二分时间,如果 v*t + dis >= f-s就好了
v*t表示*中心所能位移的路径。
dis是*上面的点所能走的距离,我们可以通过贪心得到的,首先我们可以通过t,得到这个点究竟转过了多少的角度
要让*上的点走的最远,我们肯定是让他通过对称的方式走,所以可以算出一个最长距离
然后check就好了
代码
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std; const double pi = acos(-1.0);
int t;double r,v,f,s;
int check(double t)
{
double dis = v * t;
double len = fmod(dis,*pi*r);
double k = len / r / 2.0;
double dis2 = 2.0 * abs(sin(k)) * r;
if(dis + dis2 > f-s)return ;
return ;
}
int main()
{
scanf("%d",&t);
cin>>r>>v;
while(t--)
{
scanf("%lf%lf",&s,&f);
double l=0.0,r=1999999999.0;
for(int i=;i<;i++)
{
double mid=(l+r)/2.0;
if(check(mid))r=mid;
else l=mid;
}
printf("%.15f\n",l);
}
}
Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理的更多相关文章
-
Codeforces Round #330 (Div. 2) D. Max and Bike 二分
D. Max and Bike For months Maxim has been coming to work on his favorite bicycle. And quite recently ...
-
Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...
-
Codeforces Round #330 (Div. 1) C. Edo and Magnets 暴力
C. Edo and Magnets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594/pr ...
-
随笔—邀请赛前训—	Codeforces Round #330 (Div. 2) B题
题意: 这道英文题的题意稍稍有点复杂. 找长度为n的数字序列有多少种.这个序列可以分为n/k段,每段k个数字.k个数可以变成一个十进制的数Xi.要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X ...
-
随笔—邀请赛前训— Codeforces Round #330 (Div. 2) Vitaly and Night
题意:给你很多对数,要么是0要么是1.不全0则ans++. 思路即题意. #include<cstdio> #include<cstring> #include<iost ...
-
Codeforces Round #330 (Div. 1) A. Warrior and Archer 贪心 数学
A. Warrior and Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594 ...
-
Codeforces Round #330 (Div. 2) B. Pasha and Phone 容斥定理
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/pr ...
-
Codeforces Round #330 (Div. 2) A. Vitaly and Night 暴力
A. Vitaly and Night Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/p ...
-
Codeforces Round #330 (Div. 2)
C题题目出错了,unrating,2题就能有很好的名次,只能呵呵了. 水 A - Vitaly and Night /***************************************** ...
随机推荐
-
ZOJ 2334 Monkey King
并查集+左偏树.....合并的时候用左偏树,合并结束后吧父结点全部定成树的根节点,保证任意两个猴子都可以通过Find找到最厉害的猴子 Monkey King ...
-
[qemu] 在前端驱动使用virtio的情况下,如何让后端使用vhost-user [未解决]
首先,如果你更关心原理和知识,请读读这个 http://chuansong.me/n/2186528 (值得细细的逐字读). 在<<深入浅出dpdk>>中提到,vhost-us ...
-
xml架构管理器
http://technet.microsoft.com/zh-cn/dd489278
-
PMP--案例解答要点
没有相关的管理流程或方针: 没有进行良好的策划: 资源不足(人.资金.设备和工具): 缺少培训,不具备相关的知识和技能要求: 项目干系人识别不充分,干系人没有充分的介入: 缺少配置管理.变更控制和版本 ...
-
Android中xml设置Animation动画效果详解
在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...
-
[iOS Animation]-CALayer 图层几何学
图层几何学 不熟悉几何学的人就不要来这里了 --柏拉图学院入口的签名 在第二章里面,我们介绍了图层背后的图片,和一些控制图层坐标和旋转的属性.在这一章中,我们将要看一看图层内部是如何根据父图层和兄弟图 ...
-
【易语言学习】Day1
个人认为网上讲的都不是很好,查阅了各类资料,特意找了份比较不错的PDF版,需要的可以私聊我~~~ 今天就看到这里了,请听下回分解
-
Scala进阶之路-Scala函数篇详解
Scala进阶之路-Scala函数篇详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.传值调用和传名调用 /* @author :yinzhengjie Blog:http: ...
-
go编译
1. Go编译器 两种官方编译器,gc和gccgo,其中gccgo基于gcc后端. go编译器支持8种指令集,不同建构编译质量不同: amd64 (also known ) (x86 or x86-) ...
-
google打不开解决的方法
14.5.27以来.谷歌又打不开了. 从网上找了些国内的googleserverIP,例如以下: const char* g_google_ips[18] = { "203.208.48.1 ...