#include <bits/stdc++.h>
using namespace std;
int n,t;
const int N = ;
double dp[N];
/*
甩一个n面的骰子,问每一面都被甩到的需要甩的次数期望是多少。
dp[i]:已经甩到i个面了,要达到n个面还需要次数的期望
显然dp[n] = 0
那么逆序分析:dp[i] :再甩一次,有(n-i)/n的概率甩到其他的
有i/n的概率甩到已经被甩过的。
那么 dp[i]=(n-i)/n*dp[i+1]+i/n*dp[i]+1(+1是因为再甩了一次)
化简可得到 dp[i]=dp[i+1]+n/(n-i)
*/
int main()
{
scanf("%d",&t);
while(t--){
scanf("%d",&n);
dp[n] =;
for(int i =n-;i>=;i--){
dp[i] = dp[i+]+(n/(n-(double)i));
}
printf("%.2f\n",dp[]);
}
return ;
}

spoj1026 favorite dice的更多相关文章

  1. 题解:SPOJ1026 Favorite Dice

    原题链接 题目大意 给你一个n个面的骰子,每个面朝上的几率相等,问每个面都被甩到的期望次数 题解 典型的赠券收集问题. 我们考虑当你手上已有\(i\)种不同的数,从集合中任选一个数得到新数的概率,为\ ...

  2. HDOJ 4652 Dice

      期望DP +数学推导 Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  3. 三种renderman规范引擎的dice对比

    次表面做的有些烦躁,既然如此,索性先记一下前一阵比较的PIXIE.3delight.prman的dice方式. 研究过reyes的人都知道dice,简而言之,就是为了生成高质量高精度的图片(电影CG) ...

  4. LightOJ 1248 Dice (III) 概率

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

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

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

  6. 概率 Gym 100502D Dice Game

    题目传送门 /* 题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布 问两人投掷,胜利的概率谁大 数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利 还有更简单的做 ...

  7. HDU 5955 Guessing the Dice Roll

    HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...

  8. UVALive 7275 Dice Cup (水题)

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

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

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

随机推荐

  1. May 13th 2017 Week 19th Saturday

    Mountains look beautiful from a distance. 远处看山山更美. This gnomic seems to circulate very long, its mor ...

  2. March 7 2017 Week 10 Tuesday

    Age is a very high price to pay for maturity. 年纪是成熟的代价. A high price, indeed a high price. It is bes ...

  3. 保存Google、Bing翻译的语音

    以Chrome浏览器+google翻译为例,bing的下载步骤也类似 1.打开google翻译页面(translate.google.com),输入一段文本,如下图 2.可以看到,右侧已经翻译好了,这 ...

  4. 第二次scrum冲击

    1.小组第二次冲刺任务及其完成情况描述. 本次冲刺我们小组经过讨论,实现的使我们爱上长大系统中的失物招领功能,由于在实际的实现中,对于本功能的逐渐深入和了解,渐渐发现这个功能实现起来需要由很多部分组成 ...

  5. JavaMail简单应用

    版权声明:本文为博主原创文章,未经博主同意不得转载. --caicongyang https://blog.csdn.net/caicongyang/article/details/33731395 ...

  6. [USACO12FEB]牛券Cow Coupons

    嘟嘟嘟 这其实是一道贪心题,而不是dp. 首先我们贪心的取有优惠券中价值最小的,并把这些东西都放在优先队列里,然后看[k + 1, n]中,有些东西使用了优惠券减的价钱是否比[1, k]中用了优惠券的 ...

  7. HDU 5723 Abandoned country 【最小生成树&&树上两点期望】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5723 Abandoned country Time Limit: 8000/4000 MS (Java/ ...

  8. [18/11/28]Java中的包(package)

    一.为何引入包? 包机制是Java中管理类的重要手段. 开发中,我们会遇到大量同名的类,通过包我们很容易对解决类重名的问题,也可以实现对类的有效管理. 包对于类,相当于文件夹对于文件的作用.(同一文件 ...

  9. scala性能测试

    主要对比scala 的for, while循环,以及和java for while循环作对比 scala代码 object TestScalaClass { var maxindex = 100000 ...

  10. .NET 小程序 wx.getUserInfo(OBJECT) 解密 encryptedData 来获取UnionId

    在小程序中通过 wx.getUserInfo 获取用户信息,而UnionId 只有关主了公众号才会返回,不关注公众号想获取UnionId则需要我们从返回的 encryptedData 中解码从而获取U ...