码迷,mamicode.com
首页 > 其他好文 > 详细

“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--B. Salty Fish Go!

时间:2018-04-30 14:33:05      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:using   sid   https   img   win   例子   please   std   设置   

这套题的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 
技术分享图片
.
示例1

输入

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:1697782237@qq.com(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!

标签:using   sid   https   img   win   例子   please   std   设置   

原文地址:https://www.cnblogs.com/fantastic123/p/8973398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!