sgu 144 Meeting
题意:两人在x,y两时刻之间出现,先到的最多等z分钟就离开。问相遇机率。
画坐标轴,横轴表示x出现的时间点,纵轴表示y出现的时间点。过原点斜率为1的直线表示恰好相遇。上下平移z就是能相遇。
//#pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<stack> #include<map> #include<set> #include<algorithm> #include <stack> #include <iomanip> using namespace std; typedef long long lon; const int SZ=527000,INF=0x7FFFFFFF; const double EPS=1e-8; int main() { //std::ios::sync_with_stdio(0); //freopen("d:\\1.txt","r",stdin); //for(;scanf("%d",&n)!=EOF;) { double a,b,z; cin>>a>>b>>z; double ok=(b-a)*60-z; double res=((b-a)*120*z-z*z)/((b-a)*(b-a)*3600); if(ok<0||fabs(ok)<EPS)cout<<fixed<<setprecision(7)<<1<<endl; else cout<<fixed<<setprecision(7)<<(res)<<endl; } return 0; }