原题链接

题目大意

给你一个n个面的骰子,每个面朝上的几率相等,问每个面都被甩到的期望次数

题解

典型的赠券收集问题

我们考虑当你手上已有\(i\)种不同的数,从集合中任选一个数得到新数的概率,为\(\frac{n-i+1}{n}\),那期望即为\(\frac{1}{p} = \frac{n}{n-i+1}\)。所以总期望为\(\sum_{i = 1}^{n}\frac{n}{n-i+1} = \sum_{i=1}^{n}\frac{n}{i}\)。

当然也可以用概率dp来推:

我们设\(f[i]\)表示取了\(i\)种数时还须取的数的期望。

显然\(f[n] = 0\),答案为\(f[0]\),所以为逆推。

又由于选第\(i\)个数后再选一个数与已经选过的数不同的概率为\(\frac{n-i}{n}\),相同为\(\frac{i}{n}\)。

于是可得\(f[i] = \frac{n-i}{n}f[i+1]+\frac{i}{n}f[i] + 1\)。

解得\(f[i] = f[i+1] + \frac{n}{n-i}\)。

于是整理一下就变成了\(f[0] = \sum_{i=1}^{n}\frac{n}{i}\)。

题解:SPOJ1026 Favorite Dice的更多相关文章

  1. spoj1026 favorite dice

    #include <bits/stdc++.h> using namespace std; int n,t; ; double dp[N]; /* 甩一个n面的骰子,问每一面都被甩到的需要 ...

  2. 题解合集 (update on 11.5)

    收录已发布的题解 按发布时间排序. 部分可能与我的其他文章有重复捏 qwq . AtCoder for Chinese: Link ZHOJ: Link 洛谷 \(1\sim 5\) : [题解]CF ...

  3. 题解 SP1026 【FAVDICE - Favorite Dice】

    首先,这是一道经典的期望dp题 因为最终状态 $ (所有面都被筛到过) $ 是确定的,所以才用 逆推 ,设状态 $ f[i] $ 表示已经筛到了 $ i $ 个不同的面,有 $ i\over n $ ...

  4. bestcoder Round #7 前三题题解

    BestCoder Round #7 Start Time : 2014-08-31 19:00:00    End Time : 2014-08-31 21:00:00Contest Type : ...

  5. LightOJ 1248 Dice (III) 概率

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  6. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  7. UVALive 7275 Dice Cup (水题)

    Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...

  8. HDU 4586 A - Play the Dice 找规律

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. Dice Notation(模拟)

    Dice Notation Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit  ...

随机推荐

  1. VS2008 激活

    序列号:PYHYP-WXB3B-B2CCM-V9DX9-VDY8T 如果没有序列号输入框需要使用crackvs2008forwindows7工具进行修复

  2. seaborn画出的一些好看的图片

    PYSPARK_DRIVER_PYTHON=/home/zhangyu/anaconda3/bin/jupyter-notebook PYSPARK_DRIVER_PYTHON_OPTS=" ...

  3. 50-overlay 如何实现跨主机通信?

    上一节我们在 host1 中运行了容器 bbox1,今天将详细讨论 overlay 网络跨主机通信的原理. 在 host2 中运行容器 bbox2: bbox2 IP 为 10.0.0.3,可以直接 ...

  4. MySQL相关参数总结

    保留个原文链接,避免被爬虫爬了过去,以便后续更正补充:https://www.cnblogs.com/wy123/p/11273023.html MySQL参数繁多,是一个需要根据具体业务.软硬件环境 ...

  5. [转载]——Automatic Tuning of Undo_retention Causes Space Problems (文档 ID 420525.1)

    Automatic Tuning of Undo_retention Causes Space Problems (文档 ID 420525.1) 转到底部 In this Document   Sy ...

  6. enable user-defined extended attributes for ext3 file systems; 增加ext3 文件系统的扩展属性;

    To enable user-defined extended attributes for ext3 file systems (i.e. device), use: tune2fs -o user ...

  7. 将CocoStudio产生的UI文件导入到项目

    配置: Xcode 6.0 + CocoStudio 1.6 + Cocos2d-x 3.4 添加资源 将导出的资源文件放到 Resource 文件夹下. 头文件 #include "coc ...

  8. unittest---unittest断言

    在unittest单元测试中也提供了断言的方式,通过断言判断用例有没有成功. unittest常用断言 unittest框架的TestCase类提供以下方法用于测试结果的判断 方法 检查 assert ...

  9. 《Web Development with Go》Mangodb插入struct数据

    学习数据持久化. package main import ( "fmt" "log" "time" "gopkg.in/mgo.v ...

  10. Spring源码解析-ioc容器的设计

    Spring源码解析-ioc容器的设计 1 IoC容器系列的设计:BeanFactory和ApplicatioContext 在Spring容器中,主要分为两个主要的容器系列,一个是实现BeanFac ...