Problem 1609 - Han Move
Time Limit: 1000MS   Memory Limit: 65536KB    Total Submit: 620  Accepted: 162  Special Judge: No
Description
Cyy and Fzz are Han Move lovers. One day, they gather together to run. They choose a circular track whose length is L m. Cyy’s speed is A m/s and Fzz’s speed is B m/s. They may choose the direction separately, i.e. they may start with the same direction or different direction. As they’re crazy, they’ll run infinitely. Gatevin, their friend, wonders the possibility of their distance is less than D m. The distance is defined as the distance on the track. The possibility is defined as the ratio between the sum of time satisfying the condition and the total time.
Input
The input file consists of multiple test cases ( around 1000000 ). Each test case consists of 5 integers L, A, B, D, Dir in a line. The meanings of L, A, B, D are as described above. Dir means whether they are in the same direction. Dir = 1 means they are in the same direction, while Dir = 0 means they are in the opposite direction. ( 1 <= L, A, B, D <= 32768, 0 <= Dir <= 1 )
Output
For each test case, output the possibility rounded to 6 demical places in a line.
Sample Input
1200 200 400 300 0 1200 200 400 300 1
Sample Output
0.500000 0.500000
题解:两个人正反跑无限跑,问两个人距离为D以内的概率;注意细节;
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
int main(){
double L,A,B,D,ans;
int Dir;
while(~scanf("%lf%lf%lf%lf%d",&L,&A,&B,&D,&Dir)){
if(D >= L){
puts("1.000000");
continue;
}
if(D == && A == B && Dir){
puts("1.000000");
continue;
}
if(D == ){
puts("0.000000");
continue;
}
if(Dir){
if(A == B){
puts("0.000000");
continue;
}
double p1 = L / fabs(A - B);
double p2 = * D / fabs(A - B);
ans = p2 / p1;
}
else{
double p1 = L / fabs(A + B);
double p2 = * D / fabs(A + B);
ans = p2 / p1;
}
if(ans >= ){
ans = ;
}
printf("%.6lf\n",ans);
}
return ;
}

Han Move(细节题)的更多相关文章

  1. Codeforces Round #392 (Div. 2)-758D. Ability To Convert(贪心,细节题)

    D. Ability To Convert time limit per test 1 second Cmemory limit per test 256 megabytes input standa ...

  2. 【线段树 细节题】bzoj1067: [SCOI2007]降雨量

    主要还是细节分析:线段树作为工具 Description 我们常常会说这样的话:“X年是自Y年以来降雨量最多的”.它的含义是X年的降雨量不超过Y年,且对于任意Y<Z<X,Z年的降雨量严格小 ...

  3. zoj 3745 Salary Increasing(坑爹的细节题!)

    题目 注意题目中的,引用绝望的乐园中的进一步解释如下: 这是一道浙大月赛的题,一如既往的坑爹,好好一道水题,被搞成一道坑题!!! //注意:r(i) < l(i+1) !细节啊细节! #incl ...

  4. 【交互 细节题 思维题】cf1064E. Dwarves, Hats and Extrasensory Abilities

    第一次做交互真有趣……:挺好的细节思维题 This is an interactive problem. In good old times dwarves tried to develop extr ...

  5. bzoj1067——SCOI2007降雨量(线段树,细节题)

    题目描述 我们常常会说这样的话:"X年是自Y年以来降雨量最多的".它的含义是X年的降雨量不超过Y年,且对于任意\(Y<Z<X\),Z年的降雨量严格小于X年.例如2002 ...

  6. Codeforces 571E - Geometric Progressions(数论+阿巴细节题)

    Codeforces 题目传送门 & 洛谷题目传送门 u1s1 感觉此题思维难度不太大,不过大概是细节多得到了精神污染的地步所以才放到 D1E 的罢((( 首先我们对所有 \(a_i,b_i\ ...

  7. An Easy Problem?!(细节题,要把所有情况考虑到)

    http://poj.org/problem?id=2826 An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  8. TOJ3955: NKU ACM足球赛(并查集+map+细节题)

    时间限制(普通/Java):5000MS/15000MS     内存限制:65536KByte 描述 NKU ACM最近要举行足球赛,作为此次赛事的负责人,Lee要对报名人员进行分队.分队要遵循如下 ...

  9. BZOJ3444 最后的晚餐【细节题+组合数学】*

    BZOJ3444 最后的晚餐 Description [问题背景] 高三的学长们就要离开学校,各奔东西了.某班n人在举行最后的离别晚餐时,饭店老板觉得十分纠结.因为有m名学生偷偷找他,要求和自己暗恋的 ...

随机推荐

  1. 如何在已经存在python2的linux环境上安装python3

    最近看到好多人都在问在已经存在python2.7的环境下如何安装python3,于是我决定写下这篇文档,供大家学习参考,希望能够给大家带来帮助 有的人在安装的时候可能会先将python2卸载掉,这个地 ...

  2. 关于NetBeans IDE的配置优化

    首先,IDE的版本最好对应着JDK的版本. NetBeans优化的目的是提高NetBeans的启动速度和运行速度.下面介绍的NetBeans优化技巧是在版本6.0beta2上的优化.经过实验,大大提高 ...

  3. POJ 3254 炮兵阵地(状态压缩DP)

    题意:由方格组成的矩阵,每个方格可以放大炮用P表示,不可以放大炮用H表示,求放最多的大炮,大炮与大炮间不会互相攻击.大炮的攻击范围为两个方格. 分析:这次当前行的状态不仅和上一行有关,还和上上行有关, ...

  4. 我的第一个Servlet

    学了一个学期JEE,明天就要考试了. 在3月份自己開始准备去努力的复习考研的高数还有英语等学科. 结果到如今才发现,虽说是考的计算机(本专业的)可是考研和技不可兼得. 想想自己没准备考研的时候的每天大 ...

  5. php的一些特殊用法

    php ruturn的另一个用法 database.php <?php return array ( 'hostname' => 'localhost', 'database' => ...

  6. SQL Server事务的存储过程

    在酒店管理系统开发中,我们会创建房间表和房间类型表(房型表)这两个表,如下图所示: 房型表:RoomType 房间表:Room 首先这两个表的关系:Room是从表,RoomType是主表,两表有主外键 ...

  7. Mock测试框架

    一.前言 使用Mock框架进行单元测试,能够使用当前系统已经开发的接口方法模拟数据.(未写完,慢慢完善) 二.例子 1.引用Moq

  8. netCDF

    NetCDF started in 1989 most used in geoscience community array-oriented self-describing header, desc ...

  9. CentOS安装配置ganglia

    1.     下载ganglia源码包并解压 wget http://sourceforge.net/projects/ganglia/files/ganglia%20monitoring%20cor ...

  10. php代码查询apache模块

    <?php print_r(apache_get_modules()); ?> 注:此函数仅适用于CGI模式.