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 ...
随机推荐
- 双态运维联盟(BOA)正式成立
3月1日,由联想.新华三.华为等12家IT企业在北京正式达成协议,联合发起成立“双态运维联盟”.中国电子工业标准技术协会.信息技术服务分会数据中心运营管理工作组(DCMG)组长肖建一先生出席了会议. ...
- (2.3)DDL增强功能-流程化控制与动态sql
1.流程控制 在T-SQL中,与流程控制语句相关的关键字有8个: BEGIN...END BREAK GOTO CONTINUE IF...ELSE WHILE RETURN WAITFOR 其实还可 ...
- android showDialog用法
protected Dialog onCreateDialog(int id) { // TODO Auto-generated method stub switch(id){ case 10: re ...
- 23.如何查看一个keystore的具体签名信息
keytool -list -v -keystore zhangzu.keystore
- 用 node.js 的 hexo 框架搭建一个支持 markdown 的静态博客系统
1,Hexo如何在线可视化写博客: 可以试试这款插件 hexo-admin. 2,马克飞象: 一个非常好的 markdown 编辑器. 3,Hexo博客文章设置密码的方法: 首先,在Hexo中 ...
- HDU1452:Happy 2004(求因子和+分解质因子+逆元)上一题的简单版
题目链接:传送门 题目要求:求S(2004^x)%29. 题目解析:因子和函数为乘性函数,所以首先质因子分解s(2004^x)=s(2^2*x)*s(3^x)*s(167^x); 因为2与29,166 ...
- log4j2高级配置(1)
一.Log4j2高级配置介绍(1) (1)日志输出到文件配置 <!-- 将日志输出到指定位置的文件中 --> <RollingFile name="RollingFi ...
- 利用 TestNG 并行执行用例
原文地址https://testerhome.com/topics/1639 一.测试类*注1 package com.testerhome; import io.appium.java_client ...
- 39XML文档类
Xml源代码 domxml.h #ifndef DOMXML_H #define DOMXML_H #include <QString> #include <QStringList& ...
- 2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017) Solution
A - Airport Coffee 留坑. B - Best Relay Team 枚举首棒 #include <bits/stdc++.h> using namespace std; ...