[spoj Favorite Dice ][期望dp]】的更多相关文章

(1)https://vjudge.net/problem/SPOJ-FAVDICE 题意:有一个n面的骰子,每一面朝上的概率相同,求所有面都朝上过至少一次的总次数期望. 题解:令dp[i]表示 i 面满足条件的期望次数,则有 dp[i]=$\sum_{j=1}^{i-1}$(Pj*(本次操作对最终期望的贡献+dp[i]))+$\sum_{j=1}^{n-(i-1)}$(Qj*(本次操作对最终期望的贡献+dp[i-1])),其中Pj表示出现已经出现过数字的概率,由于是等概率事件,所以这里所有的P…
题意: 一个骰子,n个面,摇到每一个面的概率都一样.问你把每一个面都摇到至少一次需要摇多少次,求摇的期望次数 题解: dp[i]:已经摇到i个面,还需要摇多少次才能摇到n个面的摇骰子的期望次数 因为我们只知道dp[n]的值,所以我们只能倒推,dp[n]=0(感觉大部分概率dp都是倒推~~~~) dp[i]=i/n*dp[i]+(n-i)/ndp[i+1]+1 化简一下: dp[i]=dp[i+1]+n/(n-i) 代码: #include<stdio.h> #include<string…
也许更好的阅读体验 \(\mathcal{Description}\) 一个\(n\)面的骰子,求期望掷几次能使得每一面都被掷到 输入有\(T\)组数据,每次输入一个\(n\) 输出保留两位小数 \(\mathcal{Solution}\) 设\(f[i]\)表示已经掷到过\(i\)面,还 期望掷多少次骰子使每一面都被掷到 现在掷一次骰子,有两种情况 有\(\frac{i}{n}\)的概率掷到已经掷到过的面,此时仍然还要掷\(f[i]\)次骰子 有\(\frac{n-i}{n}\)的概率掷到没掷…
题目链接:LightOJ - 1248 Description Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz s…
Aeroplane chess Time Limit: 1 Sec  Memory Limit: 32 MB[Submit][Stataus][Discuss] Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have s…
传送门:http://www.lightoj.com/volume_showproblem.php?problem=1030 Discovering Gold Time Limit: 2 second(s) Memory Limit: 32 MB Program Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can con…
题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 \times N\) grid. Each cell of the cave can contain any amount of gold. Initially you are in position \(1\). Now each turn you throw a perfect \(6\) s…
1419: Red is good Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 660  Solved: 257[Submit][Status][Discuss] Description 桌面上有R张红牌和B张黑牌,随机打乱顺序后放在桌面上,开始一张一张地翻牌,翻到红牌得到1美元,黑牌则付出1美元.可以随时停止翻牌,在最优策略下平均能得到多少钱. Input 一行输入两个数R,B,其值在0到5000之间 Output 在最优策略下平均能得到多少钱…
[NOIP2016]换教室 D1 T3 Description 对于刚上大学的牛牛来说, 他面临的第一个问题是如何根据实际情况中情合适的课程. 在可以选择的课程中,有2n节课程安排在n个时间段上.在第 i ( 1≤ i≤n)个时同段上, 两节内容相同的课程同时在不同的地点进行, 其中, 牛牛预先被安排在教室 ci上课, 而另一节课程在教室 di进行. 在不提交任何申请的情况下,学生们需要按时间段的顺序依次完成所有的n节安排好的课程.如果学生想更换第i节课程的教室,则需要提出中情.若申请通过,学生…