当前位置:网站首页>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
边栏推荐
- When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
- Write a jump table
- Dachang classic pointer written test questions
- 恢复持久卷上的备份数据
- awk处理JSON处理
- Cantata9.0 | new features
- Implement secondary index with Gaussian redis
- Update iteration summary of target detection based on deep learning (continuous update ing)
- CodeSonar网络研讨会
- 【函数递归】简单递归的5个经典例子,你都会吗?
猜你喜欢
Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
Apifox 接口一体化管理新神器
如何满足医疗设备对安全性和保密性的双重需求?
Codesonar enhances software reliability through innovative static analysis
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
MySQL约束之默认约束default与零填充约束zerofill
[paper reading] maps: Multi-Agent Reinforcement Learning Based Portfolio Management System
Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]
Measure the height of the building
OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
随机推荐
有用的win11小技巧
恶魔奶爸 B1 听力最后壁垒,一鼓作气突破
使用高斯Redis实现二级索引
写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
Écrivez une liste de sauts
Alibaba cloud award winning experience: how to mount NAS file system through ECS
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System
基于深度学习的目标检测的更新迭代总结(持续更新ing)
Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance
Cantata9.0 | 全 新 功 能
Nebula Importer 数据导入实践
备份 TiDB 集群到持久卷
Micro service remote debug, nocalhost + rainbow micro service development second bullet
Small guide for rapid formation of manipulator (12): inverse kinematics analysis
阿里云有奖体验:如何通过ECS挂载NAS文件系统
Introduction to referer and referer policy
Spark 判断DF为空
C语言多角度帮助你深入理解指针(1. 字符指针2. 数组指针和 指针数组 、数组传参和指针传参3. 函数指针4. 函数指针数组5. 指向函数指针数组的指针6. 回调函数)
万字总结数据存储,三大知识点
如何满足医疗设备对安全性和保密性的双重需求?