嘟嘟嘟

虽然分类是期望dp,不过好像是最水的

因为在陆地上的时间和概率是固定的,所以只用考虑过河的期望时间。

对于一条河p, l, v,p好像没什么用……不管了,首先期望时间我觉得可以这么算:期望时间=期望距离 / 速度,又因为船停的位置和方向都是等概率随机的,所以期望的距离就是平均距离,很显然最长的距离是3L,最短是L,那么平均距离就是2L,期望时间就是2L / v。

初始化ans = d,那么每一次ans = ans - L + 2L / v.

 #include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a) memset(a, 0, sizeof(a))
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-;
//const int maxn = ;
inline ll read()
{
ll ans = ;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) {last = ch; ch = getchar();}
while(isdigit(ch)) {ans = ans * + ch - ''; ch = getchar();}
if(last == '-') ans = -ans;
return ans;
}
inline void write(ll x)
{
if(x < ) x = -x, putchar('-');
if(x >= ) write(x / );
putchar(x % + '');
} int n, d, cnt = ; int main()
{
while(scanf("%d%d", &n, &d) && (n || d))
{
db ans = d;
for(int i = ; i <= n; ++i)
{
int p = read(), l = read(), v = read();
ans = ans - l + * (db)l / (db)v;
}
printf("Case %d: %.3lf\n\n", ++cnt, ans);
}
return ;
}

UVA 12230 Crossing Rivers的更多相关文章

  1. UVA 12230 - Crossing Rivers(概率)

    UVA 12230 - Crossing Rivers 题目链接 题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,如今要求从A到B,所须要的期望时间 思路:每条河的期望,最坏就是船刚开 ...

  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 概率期望

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

  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. 图标插件FusionChartsFree

    二.介绍 Ø FusionCharts 是InfoSoft Global 公司的一个产品,InfoSoft Global 公司是专业的Flash 图形方案提供商,他们还有几款其他的,基于Flash 技 ...

  2. Spring.Net---1、IOC第一个实例

    Spring.NET IoC容器的用法. 通过简单的例子学习Spring.Net 1.先创建一个控制台程序项目. 2.添加IUserInfoDal 接口. namespace Spring.Net { ...

  3. JSP简单实现登录和注销

    JSP简单实现登录和注销 需求:用户登录成功后跳转到欢迎页面 用户登录失败跳转到初始的登录界面 用户点击注销,用户退出登录状态需要重新登录 登录页面的JSP代码: <%@ page langua ...

  4. PowerDesigner16使用方法

    网上下载一个破解版的PowerDesigner https://www.cnblogs.com/longshiyVip/p/4643871.html 1.新建一个Physical Data Model ...

  5. Thymeleaf学习记录(7)--页面引入/片段引入

    1.为页面添加footer: Templates文件夹下新建HTML文件: <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xh ...

  6. 利用localStorage事件来跨标签页共享sessionStorage

    //干货 利用localStorage事件来跨标签页共享sessionStorage //因为cookie保存字节数量有限,很多童鞋考虑用html5 storage来保存临时数据,Sessionsto ...

  7. css中小知识点总结

    rgba:即rgb+a, a为图片透明度,a范围是0~1,越小就表示越透明 :hover 即鼠标悬停时改变样式,不仅仅能用在a元素上. <form>标签表示向浏览器提交表单,一般会包裹着输 ...

  8. AE+C#实现:在SceneControl里打开和保存

    来自:http://www.cnblogs.com/zhuxy/archive/2012/03/30/2424672.html 之前编写这段代码,发现一直没有C#编写的,现在贴出来,希望对大家有用 此 ...

  9. Reporting Service 2005 迁移 到 2008

    1. 备份ReportServer 和ReportServerTempDB 的数据库. 2. 在Reporting Services Configuration Manager 中备份Encrypti ...

  10. (WF, Debug) System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:xx;assembly=xx}xx'.

    Load WF 后一开始运行的时候就发现 System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespa ...