UVA - 12230

 

复制代码
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int  n;
 4 double d;
 5 double p,l,v,ret,sum;
 6 int cnt =1;
 7 /*
 8 
 9     村庄A,B之间有若干条河流,每条河流上的船速各自保持不变。告诉河流条数,两个村庄之间的距离
10     以及每条河流的距离A村庄的位置,宽度,船的速度。求A到B的时间的期望。
11     
12     过河:最多用时:3*l/v,最少用时l/v。
13     因为开始时船的位置随机,所以期望过河时间为2L/v。加上在路上行走的时间就是答案。
14 */
15 int main()
16 {
17     while(~scanf("%d%lf",&n,&d)){
18         if(n+d==0) break;
19         ret= 0.0;sum = 0.0;
20         for(int i =0;i<n;i++){
21             scanf("%lf%lf%lf",&p,&l,&v);
22             sum+=l;
23             ret+=2.0*l/v;
24         }
25         ret+=(d-sum);
26         printf("Case %d: %.3f\n\n",cnt++,ret);
27     }
28     return 0;
29 }
复制代码

 

posted on   cltt  阅读(88)  评论(0编辑  收藏  举报

努力加载评论中...
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示