【LightOJ 1248】Dice (III)(概率DP)
来源:互联网 发布:联通网络测速手机版 编辑:程序博客网 时间:2024/04/29 18:29
【LightOJ 1248】Dice (III)(概率DP)
题目大意:
一个n面的正n面体,每次抛出,每面朝上的概率一样。问每个面都超上过所需要抛的次数的期望。
k表示当前还没看到的面的数量
化简后就是
记得最起初接触概率DP是去年,然而对于期望这种一直没有真正的明白,意义很含糊,最近认真来刷,感觉慢慢开始悟出来了。假设当前这步期望一直真的很重要!之后化简之类的很好做了就
代码如下:
#include <iostream>#include <cmath>#include <vector>#include <cstdlib>#include <cstdio>#include <climits>#include <ctime>#include <cstring>#include <queue>#include <stack>#include <list>#include <algorithm>#include <map>#include <set>#define LL long long#define Pr pair<int,int>#define fread(ch) freopen(ch,"r",stdin)#define fwrite(ch) freopen(ch,"w",stdout)using namespace std;const int INF = 0x3f3f3f3f;const int msz = 100001;const int mod = 1e9+7;const double eps = 1e-8;double dp[msz];int main(){ //fread(""); //fwrite(""); int t,n; scanf("%d",&t); for(int z = 1; z <= t; ++z) { scanf("%d",&n); dp[1] = n; for(int i = 2; i <= n; ++i) dp[i] = dp[i-1]+1.0*n/i; printf("Case %d: %.11f\n",z,dp[n]); } return 0;}
0 0
- 【LightOJ 1248】Dice (III)(概率DP)
- lightOJ 1248 - Dice (III) 概率DP
- lightOj 1248 Dice (III) 概率公式
- LightOJ - 1248 Dice (III) 期望 + dp
- LightOj 1064 Throwing Dice(概率dp)
- light oj 1248 - Dice (III)(概率dp)
- Light OJ 1248 - Dice (III) 概率DP
- LightOJ 1248 Dice (III)
- lightoj 1248 Dice (III)
- LightOJ 1248 Dice (III)
- LightOJ 1248Dice (III)
- LightOJ1248---Dice (III)(概率dp)
- LightOJ-1248-Dice (III) (数学期望)
- LightOJ 1248 Dice (III) [期望]
- lightoj - 1064 - Throwing Dice - dp / 概率dp
- LightOJ 1064 Throwing Dice 概率DP
- LightOJ 1064 - Throwing Dice(概率DP)
- lightoj 1248 Dice (III)(几何分布+期望)
- BFS
- usaco 2.3.2 nocows
- 关于android解决多线程并发的问题
- CentOS6.5搭建LNMP
- Java第三章习题3-6(完数)
- 【LightOJ 1248】Dice (III)(概率DP)
- UI层自动化测试框架(六):持续集成和测试报告
- cocos2d-x--->飞机大战的总结0913
- 1116. Come on! Let's C
- android轻量级开源缓存框架——ASimpleCache(ACache)源码分析
- swith & if 应用场景 及区别
- 隐藏,覆盖,重载的区别
- Andrew Ng -machine learning 课堂笔记(一)第六周
- Android 设计模式 之 单例模式