嘟嘟嘟

虽然分类是期望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. 使用k8s创建容器一直处于ContainerCreating状态

    容器报错信息为(两种): FailedSynError syncing pod, skipping: failed to {kubelet 127.0.0.1} Warning FailedSync ...

  2. 基于asp.net mvc的近乎产品开发培训课程(第一讲)

    演示产品源码下载地址:http://www.jinhusns.com/Products/Download 

  3. 《Centos服务器版安装教程》

    安装前准备: (1)  首先大家需要在电脑上安装一个VMware (2)  Centos7系列的一个服务器版镜像 有了这两样东西,下面我们就开始安装了 一.     打开VMware,新建一个虚拟机 ...

  4. golang学习之slice基本操作

    slice的增删改查: //删除 func remove(slice []interface{}, i int) []interface{} { // copy(slice[i:], slice[i+ ...

  5. 设置placeholder的字体颜色

    //设置字体颜色 [self.searchTextField setValue:[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.0] f ...

  6. Thymeleaf学习记录(8)--表达式基本对象

    基础对象 #ctx:上下文对象 /* * ====================================================================== * See ja ...

  7. python中单下划线和双下滑线

    使用单下划线(_one_underline)开头表示方法不是API的一部分,不要直接访问(虽然语法上访问也没有什么问题). 使用双下划线开头(__two_underlines)开头表示子类不能覆写该方 ...

  8. python中类变量和实例变量

    1. 类变量和实例变量 在Python Tutorial中对于类变量和实例变量是这样描述的: Generally speaking, instance variables are for data u ...

  9. 2806 红与黑 个人博客:doubleq.win

    个人博客:doubleq.win 2806 红与黑  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 白银 Silver 题解  查看运行结果     题目描述 Descripti ...

  10. NGINX本地服务器解析域名

    1.找到hosts文件 ,添加需要解析的域名 2.在cmd命令窗口中检测解析是否生效 3 找到本地服务器的域名配置文件:添加绑定的域名,更改访问的目录 4.添加pathinfo.隐藏index.php ...