144. Meeting

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

Two of the three members of the winning team of one of the ACM regional contests are going to meet in order to train for the upcoming World Finals. They decided that they will meet sometime between X o'clock andY o'clock. Because they never get anywhere on time (they were late even on the day of the regional contest), they did not set an exact time when they will meet. However, they decided that the one who gets first at the meeting point will not wait more than Z minutes for the other one (they calculated that, if the other one will not come within Z minutes from the arrival of the first of them, then it is very probable that he will not show up at all). 
Knowing that, in the end, both of them will show up at some time between X o'clock and Y o'clock (not necessarily after an integer number of minutes), compute which is the probability that they will actually meet.

Input

The input will contain 2 integer numbers X and Y (0<=X<Y<=24) and one real number Z ( 0 < Z <= 60*(Y-X) ).

Output

You should output the required probability with 7 decimal digits (rounded according to the 8th decimal digit).

Sample Input

11 12 20.0

Sample Output

0.5555556

思路:就设x为A到达的时间,y为B到达的时间,那么正方形(0,0)->((y-x)*60,(y-x)*60)就是可能的概率范围,那么其中可以等到的是y=x+z和y=x-z这两条直线切掉正方形之后剩下的部分,二切掉的面积可以简单求出
#include<cstdio>
#include <cmath>
using namespace std;
int x,y;
double z; int main(){
scanf("%d%d%lf",&x,&y,&z);
double txy=abs(y-x)*60.000;
double ans=(2*txy*z-z*z)/(txy*txy);
printf("%.7f\n",ans);
return 0;
}

  

SGU 144. Meeting 概率dp 几何概率分布 难度:0的更多相关文章

  1. poj 2096 Collecting Bugs 概率dp 入门经典 难度:1

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 2745   Accepted: 1345 ...

  2. SGU 144.Meeting

    题目: 两支地区ACM比赛的队伍决定为了国际决赛而在一起集训. 他们约定在某天的 X 时到 Y 时的某一时刻相会. 但由于他们很少按时到 (有的队伍比赛那天都会迟到), 他们没有设定一个确切的相遇时间 ...

  3. POJ 1202 Family 概率,DP,高精 难度:2

    http://poj.org/problem?id=1202 难度集中在输出格式上,因为输出格式所以是高精度 递推式: 血缘肯定只有从双亲传到儿子的,所以,设f,m为双亲,son为儿子,p[i][j] ...

  4. 快速切题 sgu 111.Very simple problem 大数 开平方 难度:0 非java:1

    111.Very simple problem time limit per test: 0.5 sec. memory limit per test: 4096 KB You are given n ...

  5. 快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1

    112. a^b-b^a time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural num ...

  6. 概率dp——处理分母为0的情况hdu3853

    很水的题,但要注意的是必须处理分母为0的情况 #include<bits/stdc++.h> using namespace std; ; ; ],e[maxn][maxn]; int r ...

  7. SGU 422 Fast Typing(概率DP)

    题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...

  8. SGU 495 Kids and Prizes:期望dp / 概率dp / 推公式

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意: 有n个礼物盒,m个人. 最开始每个礼物盒中都有一个礼物. m个人依次随 ...

  9. ZOJ 3822 Domination 概率dp 难度:0

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

随机推荐

  1. Django - rest - framework - 上

    一.快速实例 http://www.django-rest-framework.org/tutorial/quickstart/#quickstart http://www.cnblogs.com/y ...

  2. vue - vue

    一.vue - 介绍 vue的作者叫尤雨溪,中国人.自认为很牛逼的人物,也是我的崇拜之神. 关于他本人的认知,希望大家读一下这篇关于他的文章,或许你会对语言,技术,产生浓厚的兴趣.https://mp ...

  3. Python开发【Django】:缓存、信号

    缓存 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者memcache ...

  4. Redis缓冲区设置

    对于Redis服务器的输出(也就是命令的返回值)来说,其大小通常是不可控制的.有可能一个简单的命令,能够产生体积庞大的返回数据.另外也有可能因为执行了太多命令,导致产生返回数据的速率超过了往客户端发送 ...

  5. JS操作符转化数字

    在Node.js源代码里,随处可见使用各种符号处理字符串为数字的.可能由于不同人编写,使用的风格也各有不同. 基本上有下面几种. 将字符串转化为数字 + 将一个数字的字符串转化为数字很简单的一种做法就 ...

  6. SWIG和PInvoke学习(1)

    1. 简介 SWIG是个帮助使用C或者C++编写的软件能与其它各种高级编程语言进行嵌入联接的开发工具. SWIG能应用于各种不同类型的语言包括常用脚本编译语言例如Perl, PHP, Python, ...

  7. python基础(基础数据类型)

    一. 引子 1. 什么是数据 x=10,10是我们要存储的数据 2. 为何数据要分不同的类型 数据是用来表示状态的,不同的状态就应该用不同的类型的数据去表示 3.数据类型 数字 字符串 列表 元组 字 ...

  8. PAT 1100 Mars Numbers[难]

    1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...

  9. 史上最强网推案例,没有之一【ZW团队实战经典】

    ZW团队认为,互联网本质只有两个字:颠覆. ZW网络推广团队,是国内首个教父级网络营销团队,自1997年以来,先后参与操盘多个重大互联网项目,服务过超过150家国际500强客户,是微软公司首家官方认证 ...

  10. 根据源Excel文件,新建Excel文件

    /** * 描述:根据源Excel文件,创建新的Excel文件 * @param excelFile * @throws CheckException */public static void cre ...