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引擎 UGUI

    Unity UGUI讲解 1.导入UI图片资源 2.设置参数: TextureType(纹理类型) 精灵 2D and UI SpriteMode(精灵模式)  Single(单) multiple( ...

  2. Microsoft SQL Server学习(二)--数据库的语法

    关于数据库的语法 创建数据库 样例 名词概念 编写数据库代码的注意事项 关于文件语法 实例代码 关于数据库的语法: 1.创建数据库 create database 数据库名 on primary (主 ...

  3. Nginx 重新加载日志配置

    最近在写一个nginx日志的切割脚本,切割完后,发现可以不重启服务,而直接重新加载日志配置文件的命令 [   kill -USR1 $nginx.pid   ],但是不知道 -USR1这个参数是什么意 ...

  4. Caffe2:python -m caffe2.python.operator_test.relu_op_test

    1. 进行语句测试时候,出现问题, 设置环境变量CUDA_VISIBLE_DEVICES 参考: cuda设置指定可见方法 在/etc/profile文件或者-/.bashrc末尾添加以下行: exp ...

  5. Operation Queues 面向对象的封装

    Operation Queues An operation queue is the Cocoa equivalent of a concurrent dispatch queue and is im ...

  6. day07补充-数据类型总结及拷贝

    目录 数据类型总结 按照存一个值 OR 多个值来分 按照有序 OR 无序来分 按照可变 OR 不可变来分 拷贝 && 浅拷贝 && 深拷贝&& .cop ...

  7. 怎么设置font awesome图标的大小?

    <i class="fa fa-camera-retro fa-lg"></i> fa-lg <i class="fa fa-camera- ...

  8. JS数组reduce()方法

    1.语法 arr.reduce(callback,[initialValue]) reduce 为数组中的每一个元素依次执行回调函数,不包括数组中被删除或从未被赋值的元素,接受四个参数:初始值(或者上 ...

  9. Array的内置方法思维导图整理(JavaScript)

    按照MDN整理的数组部分的思维导图,主要目的是方便查漏补缺,所以写的不是很详细.

  10. Node.js之错误处理

    Node.js之错误处理 1. 使用 domain 模块处理错误 try..catch 多用于捕捉同步方法中的抛出错误,但不能用try..catch捕捉异步方法中抛出de错误 如: 1 var htt ...