D. Max and Bike

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.

Input

The first line contains three integers nr 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 test(s)
input
2 1 2
1 10
5 9
output
3.849644710502
1.106060157705 题意:给你一个f,s点,一个轮子有向右的速度v,任取轮子上,一点旋转过去,问你最少多少时间
题解
可以先算出至少圈度,再二分算出多余的角度 , 利用对于圆角度 2*x=2*r*sin(@/2);
二分。
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a)); inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//****************************************
const double PI = 3.1415926535897932384626433832795;
const double EPS = 5e-;
#define maxn 100000+500
#define mod 1000000007 int main() {
for (int n, r, v; ~scanf("%d %d %d", &n, &r, &v); ) {
for (int i = ; i < n; ++i) {
int s, f;
scanf("%d %d", &s, &f);
double dist = f - s;
double t = floor(dist / ( * PI * r));
double remain = dist - t * * PI * r;
double lower = , upper = * PI;
while (lower + 1e- < upper) {
double mid = (lower + upper) / ;
if ( * sin(mid / ) * r + mid * r < remain) {
lower = mid;
} else {
upper = mid;
}
}
double len = t * * PI * r + upper * r;
printf("%.12f\n", len / v);
}
}
return ;
}

代码

Codeforces Round #330 (Div. 2) D. Max and Bike 二分的更多相关文章

  1. Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理

    D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/probl ...

  2. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  3. 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 ...

  4. Codeforces Round #706 (Div. 2)B. Max and Mex __ 思维, 模拟

    传送门 https://codeforces.com/contest/1496/problem/B 题目 Example input 5 4 1 0 1 3 4 3 1 0 1 4 3 0 0 1 4 ...

  5. 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) B题

    题意: 这道英文题的题意稍稍有点复杂. 找长度为n的数字序列有多少种.这个序列可以分为n/k段,每段k个数字.k个数可以变成一个十进制的数Xi.要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X ...

  6. 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) Vitaly and Night

    题意:给你很多对数,要么是0要么是1.不全0则ans++. 思路即题意. #include<cstdio> #include<cstring> #include<iost ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Unity学习-工具准备(一)

    工具介绍 Unity 4.5.4 VS2013 Visual Studio 2013 Tools for Unity unity3d圣典 五大面板 Hierarchy:场景资源面板 [管理 当前场景 ...

  2. jQuery——开关灯

    js对象与jquery对象的相互转化: 1.$(js对象) 2.$(selector).get(索引).$(selector)[索引] <!DOCTYPE html> <html l ...

  3. 控制台——args参数的赋值方法

    args参数的赋值方法有好几种,主要介绍两种. 外部传参的方法:先找到bin目录下的exe文件,并创建快捷方法,在目标后面追加参数. 控制台主函数入口实现方法 static void Main(str ...

  4. SSH整合框架+mysql简单的实现

    SSH整合框架+mysql简单的实现 1. 框架整合原理: struts2整合Spring 两种: 一种struts2自己创建Action,自动装配Service : 一种 将Action交给Spri ...

  5. python 求一个文件中每个字符出现的次数

    import pprint import collections filename = input('Input filename') with open(filename) as info: cou ...

  6. 深入理解Three.js(WebGL)贴图(纹理映射)和UV映射

    本文将详细描述如何使用Three.js给3D对象添加贴图(Texture Map,也译作纹理映射,“贴图”的翻译要更直观,而“纹理映射”更准确.).为了能够查看在线演示效果,你需要有一个兼容WebGL ...

  7. vue踩坑之路--点击按钮改变div样式

    有时候,我们在做项目的时候,想通过某个按钮来改变某个div样式,那么可以通过以下代码实现: <!DOCTYPE html> <html> <head> <me ...

  8. MySQL之SQL优化详解(一)

    目录 慢查询日志 1. 慢查询日志开启 2. 慢查询日志设置与查看 3.日志分析工具mysqldumpslow   序言: 在我面试很多人的过程中,很多人谈到SQL优化都头头是道,建索引,explai ...

  9. C#关键字详解第三节

    byte:字节 字节是计算机信息技术用于计量存储容量的一种计量单位,通常情况下一字节等于八位,也在一些计算机编程 语言中表示数据类型和语言字符.这是百度百科给出的解释,在C#语言中byte也可以是一种 ...

  10. hadoop-hdp-ambari离线安装记录

    一.系统准备 1. 创建user——ambari 2.关闭防火墙 redhat6: chkconfig iptables off /etc/init.d/iptables stop redhat7: ...