SGU 144. Meeting 概率dp 几何概率分布 难度:0
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的更多相关文章
- poj 2096 Collecting Bugs 概率dp 入门经典 难度:1
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 2745 Accepted: 1345 ...
- SGU 144.Meeting
题目: 两支地区ACM比赛的队伍决定为了国际决赛而在一起集训. 他们约定在某天的 X 时到 Y 时的某一时刻相会. 但由于他们很少按时到 (有的队伍比赛那天都会迟到), 他们没有设定一个确切的相遇时间 ...
- POJ 1202 Family 概率,DP,高精 难度:2
http://poj.org/problem?id=1202 难度集中在输出格式上,因为输出格式所以是高精度 递推式: 血缘肯定只有从双亲传到儿子的,所以,设f,m为双亲,son为儿子,p[i][j] ...
- 快速切题 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 ...
- 快速切题 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 ...
- 概率dp——处理分母为0的情况hdu3853
很水的题,但要注意的是必须处理分母为0的情况 #include<bits/stdc++.h> using namespace std; ; ; ],e[maxn][maxn]; int r ...
- SGU 422 Fast Typing(概率DP)
题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...
- SGU 495 Kids and Prizes:期望dp / 概率dp / 推公式
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意: 有n个礼物盒,m个人. 最开始每个礼物盒中都有一个礼物. m个人依次随 ...
- ZOJ 3822 Domination 概率dp 难度:0
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
随机推荐
- Python多进程编程(转)
原文:http://www.cnblogs.com/kaituorensheng/p/4445418.html 阅读目录 1. Process 2. Lock 3. Semaphore 4. Even ...
- python pip源配置
一.Linux版本: linux的文件存放在:~/.pip/pip.conf 二.windows版本: 在用户文件夹下创建pip目录,并在pip目录下创建pip.ini文件(%HOME%\pip\pi ...
- mysql查询乱码解决方法
http://blog.csdn.net/u012408083/article/details/52734762 MySQL 命令行查询乱码 编码问题 当使用数据库工具查询数据时显示数据正常,中文也很 ...
- Selenium之IE浏览器的启动
1.下载IEDriverServer.exe文件放至需要的目录中: 2.编写代码 import org.openqa.selenium.WebDriver; import org.openqa.sel ...
- windows下和linux下libcurl安装
下载源代码,在winbuild里面有个说明文件: Building with Visual C++, prerequisites==================================== ...
- boost pool 和 object_pool
内存池(Memory Pool)是一种内存分配方式. 通常我们习惯直接使用new.malloc等API申请分配内存,这样做的缺点在于:由于所申请内存块的大小不定,当频繁使用时会造成大量的 ...
- 转载Liferay PortletPreference store()方法研究
我们对于PortletPreference 的store()用的非常广泛,很多情况下,我们一般对其进行一些设定,然后最后调用store()存储之,类似以下代码: PortletPreferences ...
- 在windows下MySQL-python的安装
安装MySQL-python下载文件PyMySQL-0.7.11.tar.gz 解压到任意目录 https://pypi.python.org/pypi/PyMySQL 然后在cmd命令行行下进行安装 ...
- python连接mysql,redis类方法
#coding:utf8 import pymysql import redis import conf '''MYSQL DB Object''' class Mysql(): def __init ...
- MFC中利用GDI+进行双缓冲作图的有关设置
这里只是在遇到实际问题的时候提出的一种解决方法,用以处理闪屏问题. 首先要做的是对GDI的一个设置问题: 在应用程序类中添加一个保护权限数据成员 class C...App: {... private ...