当前位置:网站首页>uva 12230 – Crossing Rivers(概率)「建议收藏」
uva 12230 – Crossing Rivers(概率)「建议收藏」
2022-07-07 18:44:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
题目链接:uva 12230 – Crossing Rivers
题目大意:有个人每天要去公司上班。每次会经过N条河。家和公司的距离为D。默认在陆地的速度为1,给出N条河的信息。包含起始坐标p,宽度L,以及船的速度。
船会往返在河的两岸。人到达河岸是。船的位置是随机的(包含方向)。问说人达到公司所须要的期望时间。
解题思路:陆地上的时间是固定的,仅仅须要分别计算过每条河的时间就可以。由于人到岸边时,船的位置是随机的,所以等待的时间[0,2L/v],期间是等概率的,所以过一条河的时间极为(0+2∗Lv)2+Lv=2∗Lv
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main () {
int cas = 1;
int N;
double D, p, l, v;
while (scanf("%d%lf", &N, &D) == 2 && (N || D)) {
for (int i = 0; i < N; i++) {
scanf("%lf%lf%lf", &p, &l, &v);
D = D - l + 2 * l / v;
}
printf("Case %d: %.3lf\n\n", cas++, D);
}
return 0;
}发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116447.html原文链接:https://javaforall.cn
边栏推荐
- One click deployment of any version of redis
- [paper reading] maps: Multi-Agent Reinforcement Learning Based Portfolio Management System
- FTP steps for downloading files from Huawei CE switches
- 万字总结数据存储,三大知识点
- 不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
- Data sorting in string
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- 反诈困境,国有大行如何破局?
- OneSpin | 解决IC设计中的硬件木马和安全信任问题
- 【OpenCV 例程200篇】223. 特征提取之多边形拟合(cv.approxPolyDP)
猜你喜欢
随机推荐
Nebula Importer 数据导入实践
H3C S7000/S7500E/10500系列堆叠后BFD检测配置方法
字符串中数据排序
Flask1.1.4 Werkzeug1.0.1 源码分析:路由
使用高斯Redis实现二级索引
神兵利器——敏感文件发现工具
Mysql子查询关键字的使用方式(exists)
Numerical method for solving optimal control problem (0) -- Definition
【解决】package ‘xxxx‘ is not in GOROOT
Spark 判断DF为空
Solve the problem that the executable file of /bin/sh container is not found
Helix QAC 2020.2新版静态测试工具,最大限度扩展了标准合规性的覆盖范围
智能软件分析平台Embold
4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
Referrer和Referrer-Policy简介
Écrivez une liste de sauts
How to meet the dual needs of security and confidentiality of medical devices?
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
使用高斯Redis实现二级索引
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System









