SGU 144 Meeting(水~)

来源:互联网 发布:一元云购正版源码 编辑:程序博客网 时间:2024/06/01 10:51

Description
两人约定在x点到y点之间见面,如果先到的人等待了z分钟后另一个人还没到这个人就会离开,约见失败,问两个人能够约见成功的概率
Input
第一行三个数x,y,z(0<=x < y<=24,0<=z<=60*(y-x))
Output
Sample Input
11 12 20.0
Sample Output
0.5555556
Solution
简单题,即求Y=X+z,Y=X-z,x<=X<=y,x<=Y<=y围成的面积与x<=X<=y,x<=Y<=y围成面积的比值
p=(60*(y-x)-z)(60(y-x)-z)/(60*60*(y-x)*(y-x)
Code

#include<cstdio>#include<iostream>using namespace std;int main(){    double x,y,z;    while(~scanf("%lf%lf%lf",&x,&y,&z))    {        double ans=(60*(y-x)-z)*(60*(y-x)-z)/(60*60*(y-x)*(y-x));        printf("%.7lf\n",1.0-ans);    }       return 0;}
0 0
原创粉丝点击