“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--B. Salty Fish Go!
Posted i am back
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--B. Salty Fish Go!相关的知识,希望对你有一定的参考价值。
这套题的github地址(里面包含了数据,题解,现场排名):点此
题目描述
A few days ago, WRD was playing a small game called Salty Fish Go. We can simplify the rules of the game as follows.
The road can be abstracted into a one-dimensional axis, and the length of the road is L. There are two magic doors at the ends of the road, which can instantly transfer WRD from position L to position 0, or from location 0 to location L, without spending time.
WRD can select the initial position, the initial direction of movement, and the initial speed (from the speed set).
There are some amazing gas stations on the way, whose location is random. At the gas station WRD can change speed to one of the speed set, without spending time. (Do not change direction!)
There are some jewels on the road, whose location is random. WRD needs to take away all the jewels to win the game.
How long does it take WRD to win the game?
It’s an easy game. But considering that WRD has become a salty fish without brain, all his operations are completely random. Can you calculate the expected time for him to win the game?
输入描述:
Input contains multiple test cases, please process to the end of input.
For each test case, the first line of the input contains four positive integers V (), L (), n (), m () to indicate the size of speed set, the length of the road, the number of the gas stations, the number of the jewels.
Then, there are V integers in a line, the speed set, each integer is between 1 and .
输出描述:
The output is a real number, let your answer be a, and jury‘s answer be b, your answer will be considered as correct if and only if
.
输入
2 8 1 1 2 4 2 8 1 1 2 4
输出
1.333333333 1.333333333
题意:
几天前,WRD正在玩一款名为Salty Fish Go的小游戏。我们可以按照以下方式简化游戏规则。
道路可以抽象为一维轴线,道路长度为L.在道路两端有两个魔术门,可以立即将WRD从位置L转移到位置0,或从位置0到位置0位置L,无需花时间。
WRD可以选择初始位置,初始运动方向和初始速度(从速度设置)。
途中有一些令人惊叹的加油站,其位置是随机的。在加油站,WRD可以将速度改变为设定的速度之一,而无需花时间。 (不要改变方向!)
路上有些珠宝,其位置是随机的。 WRD需要拿走所有的珠宝来赢得比赛。
WRD赢得比赛需要多长时间?
这是一个简单的游戏。但考虑到WRD已成为无脑的咸鱼,他的所有操作都是完全随机的。你能计算出他赢得比赛的预期时间吗?
输入描述:
输入包含多个测试用例,请处理至输入结束。
对于每个测试用例,输入的第一行包含四个正整数V(),L(),n(),m()来表示速度集的大小,道路的长度,加油站的数量,珠宝的数量。
然后,在一行中有V个整数
思路:一个考验数学概率论与数理统计的题目。
答案其实就是路程除以平均速度,再考虑捡珠宝的问题,题解说对于次序统计量的期望,n个数独立均匀分布的随机变量的最大值是n/(n+1)。
/* author:gsw data:2018.04.30 link:https://www.nowcoder.com/acm/contest/104/B accout:[email protected](tonygsw) */ #define ll long long #define IO ios::sync_with_stdio(false); #include<iostream> #include<algorithm> #include<math.h> #include<stdio.h> #include<string.h> using namespace std; int main() { int v,l,n,m; while(~scanf("%d%d%d%d",&v,&l,&n,&m)) { double speed=0;int tem; for(int i=0;i<v;i++) { scanf("%d",&tem); speed+=tem; } speed=speed/v; double s=double(m)*l/(double(m+1)); double ans=s/speed; printf("%.9f\n",ans); } }
以上是关于“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--B. Salty Fish Go!的主要内容,如果未能解决你的问题,请参考以下文章
2008年TI杯湖北省大学生电子设计竞赛高功率因数电源(E题)的优秀报告