UVA 12230 Crossing Rivers
虽然分类是期望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的更多相关文章
- UVA 12230 - Crossing Rivers(概率)
UVA 12230 - Crossing Rivers 题目链接 题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,如今要求从A到B,所须要的期望时间 思路:每条河的期望,最坏就是船刚开 ...
- UVA - 12230 Crossing Rivers (期望)
Description You live in a village but work in another village. You decided to follow the straight pa ...
- UVa 12230 - Crossing Rivers(数学期望)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA - 12230 Crossing Rivers 概率期望
You live in a village but work in another village. You decided to follow the straight path between y ...
- UVA.12230.Crossing Rivers(期望)
题目链接 /* 到达一条河时,船在河中的位置是随机的,所以船到达岸边需要的时间在 0~2l/v 均匀分布,所以船到岸的期望为 (0+2l/v)/2 过河需要 l/v 的时间,所以过一条河总的期望为 ( ...
- Uva - 12230 Crossing Rivers (数学期望)
你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船, 因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在 ...
- UVA - 12230 Crossing Rivers(过河)(期望)
题意:从A到B需要经过n条河,已知AB间距离D和每条河的长度L以及在该条河上的船速v,求A到B平均情况下需多长时间.陆地行走速度为1,船的位置和朝向均匀随机. 分析: 1.过一条河,最短时间L/v(无 ...
- HDU3232 Crossing Rivers 数学期望问题
Crossing Rivers ...
- HDU 3232 && UVA 12230 (简单期望)
Crossing Rivers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
随机推荐
- zabbix使用(自定义监控、自动报警)
自定义监控(制作模板) zabbix自带模板Template OS Linux (Template App Zabbix Agent)提供CPU.内存.磁盘.网卡等常规监控,只要新加主机关联此模板,就 ...
- <input>属性为number,maxlength不起作用的解决方案
<input type="text" maxlength="11" /> 效果ok, 当 <input type="number&q ...
- Code Signal_练习题_arrayChange
You are given an array of integers. On each move you are allowed to increase exactly one of its elem ...
- MyEclipse打包带源码的jar包
平时开发中,我们喜欢将一些类打包成jar包,然后在别的项目中继续使用,不过由于看不到jar包里面的类的源码了,所以也就无法调试,要想调试,那么就只能通过关联源代码的形式,这样或多或少也有一些不方便,今 ...
- Angular入门教程二
4 功能介绍 4.1数据绑定 AngularJS的双向数据绑定,意味着你可以在Mode(JS)中改变数据,而这些变动立刻就会自动出现在View上,反之亦然.即:一方面可以做到model变化驱动了DOM ...
- MySQL数据库(9)----从命令行获取元数据
1. mysqlshow 命令提供的信息与某些 SHOW 语句很相似,因此可以从命令行提示符获取数据库和表的信息. (i)列出服务器所管理的数据库: root@javis:~$ mysqlshow - ...
- Slf4j打印异常的堆栈信息
一.前言 直接用logger.info("异常信息为:"+e)或者logger.info(e.getMessage())只能记录到异常的描述信息,却没有其异常具体发生在哪一行代码. ...
- How To Install Cacti On Ubuntu 14
How To Install Cacti On Ubuntu 14.04/14.10 by anismaj Cacti is an open source web based network moni ...
- xfs参数简介
age_buffer_centisecs age_buffer_centisecs:(Min: 100 Default: 1500 Max: 720000) 多长时间设置为脏数据 xfsbufd_ ...
- centos django+Nginx+uwsgi部署
第五天 部署python3+uwsgi+nginx的博客系统 ================================ mysql基本命令 mysql mysql -p mysqladmin ...