UVA 12230 - Crossing Rivers

题目链接

题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,如今要求从A到B,所须要的期望时间

思路:每条河的期望,最坏就是船刚开走3L/V,最好就是直接上船L/V,期望为4L/V/2 = 2L/V,然后在算上陆地上的时间,就是答案

代码:

#include <stdio.h>
#include <string.h> int n;
double d, p, l, v; int main() {
int cas = 0;
while (~scanf("%d%lf", &n, &d) && n || d) {
while (n--) {
scanf("%lf%lf%lf", &p, &l, &v);
d = d - l + l * 2 / v;
}
printf("Case %d: %.3lf\n\n", ++cas, d);
}
return 0;
}

UVA 12230 - Crossing Rivers(概率)的更多相关文章

  1. UVA - 12230 Crossing Rivers 概率期望

    You live in a village but work in another village. You decided to follow the straight path between y ...

  2. UVA - 12230 Crossing Rivers (期望)

    Description You live in a village but work in another village. You decided to follow the straight pa ...

  3. UVa 12230 - Crossing Rivers(数学期望)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. UVA 12230 Crossing Rivers

    嘟嘟嘟 虽然分类是期望dp,不过好像是最水的 因为在陆地上的时间和概率是固定的,所以只用考虑过河的期望时间. 对于一条河p, l, v,p好像没什么用……不管了,首先期望时间我觉得可以这么算:期望时间 ...

  5. UVA.12230.Crossing Rivers(期望)

    题目链接 /* 到达一条河时,船在河中的位置是随机的,所以船到达岸边需要的时间在 0~2l/v 均匀分布,所以船到岸的期望为 (0+2l/v)/2 过河需要 l/v 的时间,所以过一条河总的期望为 ( ...

  6. Uva - 12230 Crossing Rivers (数学期望)

    你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船, 因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在 ...

  7. UVA - 12230 Crossing Rivers(过河)(期望)

    题意:从A到B需要经过n条河,已知AB间距离D和每条河的长度L以及在该条河上的船速v,求A到B平均情况下需多长时间.陆地行走速度为1,船的位置和朝向均匀随机. 分析: 1.过一条河,最短时间L/v(无 ...

  8. HDU3232 Crossing Rivers 数学期望问题

    Crossing Rivers                                                                                     ...

  9. HDU 3232 &amp;&amp; UVA 12230 (简单期望)

    Crossing Rivers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. Java基础之"=="和 和 equals 方法的区别

    一."=="操作符 ==操作符专门用来比较两个变量的值是否相等,也就是用于比较变量所对应的内存中所存储的数值是否相同,要比较两个基本类型的数据或两个引用变量是否相等,只能用==操作 ...

  2. 【LeetCode题意分析&解答】35. Search Insert Position

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  3. break的使用for循环嵌套

    /* Name:break的使用for循环嵌套 Copyright: By.不懂网络 Author: Yangbin Date:2014年2月21日 02:54:04 Description:以下代码 ...

  4. java的常见异常与错误总结

    算术异常类:ArithmeticExecption 空指针异常类:NullPointerException 类型强制转换异常:ClassCastException 数组负下标异常:NegativeAr ...

  5. Android开发(26)--补间动画(Tween)的实现

    补间动画(Tween Animation) 补间动画与逐帧动画在本质上是不同的,逐帧动画通过连续播放图片来模拟动画的效果,而补间动画则是通过在两个关键帧之间补充渐变的动画效果来实现的.补间动画的优点是 ...

  6. HttpUrlConnection get和post简单实现(疑惑解决)

    近期研究微信的公众平台开发.须要和微信的server进行数据读取,简单研究了下jdk自带的HttpUrlConnection类(URLConnection的子类),简单实现了一下微信的access_t ...

  7. poj 2480 (欧拉函数应用)

    点击打开链接 //求SUM(gcd(i,n), 1<=i<=n) /* g(n)=gcd(i,n),根据积性定义g(mn)=g(m)*g(n)(gcd(m,n)==1) 所以gcd(i,n ...

  8. 【中英对照】【EntLib6】【Unity】实验1:使用一个Unity容器

    Lab 1: Using a Unity Container 实验1:使用一个Unity容器 Estimated time to complete this lab: 15 minutes 估计完成时 ...

  9. SQL Server索引进阶:第八级,唯一索引

    原文地址: Stairway to SQL Server Indexes: Level 8,Unique Indexes 本文是SQL Server索引进阶系列(Stairway to SQL Ser ...

  10. Node.js 小工具--supervisor

    Node.js 在写文件的时候 一旦更改.每次都得重新运行 app.js. 很麻烦. supervisor 工具可以帮助你 监听文件改动,自动重启. sudo npm install -g super ...