Posted on 2009-06-05 14:19
Hero 閱讀(125)
評論(0) 編輯 收藏 引用 所屬分類:
代碼如詩--ACM
1 //144 .CPP_VS Accepted 23 ms 0 kb
2 /*
3 概率問題 - 用數(shù)形結(jié)合的方法來解
4 建立二維平面坐標(biāo)系
5 X軸代表A到達(dá)的時間
6 Y軸代表B到達(dá)的時間
7 正方形代表所有可能的到達(dá)時間
8 見面的情況為|X-Y|<=Z
9 轉(zhuǎn)化為線性規(guī)劃問題
10
11 求該面積與正方形的面積比
12 */
13 #include <iostream>
14 #include <string>
15 #include <algorithm>
16 using namespace std ;
17
18 const int size = 2000 ;
19
20 int tnum ;
21 double inx, iny, inz ;
22
23 int main()
24 {
25 scanf( "%lf %lf %lf", &inx, &iny, &inz ) ;
26
27 double len = (iny-inx) * 60 ;
28 double out = 1 - (len-inz)*(len-inz)/(len*len) ;
29
30 printf( "%0.7lf\n", out ) ;
31
32 return 0 ;
33 }