#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int t,n;
double dp[100010];
int main()
{
scanf("%d",&t);
int cas=1;
while(t--)
{
scanf("%d",&n);
dp[n]=0;
for(int i=n-1;i>=0;i--)
dp[i]=dp[i+1]+(double)(n)/(n-i);
printf("Case %d: %.8lf\n",cas++,dp[0]);
}
}

  这一题期初我怎么也没理解这递推方程。后来想通一个说法。

dp[i]表示您还差i面没扔出来时你扔的次数。

dp[i]=i/n*dp[i]+(n-i)/n*dp[i+1]+1;

dp[i]=dp[i+1]+(double)(n)/(n-i);
现在让我来分析一下:
为什么i/n*dp[i]+(n-i)/n*dp[i+1]呢,我觉得是(n-i)/n*(dp[i]+1)+(i+1)/n*(dp[i+1]+1)
其实这个要反着考虑一下。就是n个你选i个里面的那么造成了dp[i],不然还是dp[i+1].。这个从后往前。

Dice (III) 概率dp的更多相关文章

  1. LightOJ 1248 Dice (III) (期望DP / 几何分布)

    题目链接:LightOJ - 1248 Description Given a dice with n sides, you have to find the expected number of t ...

  2. dice 概率论 概率DP

    题目链接: http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1010&cid=459 找出公式,公式有实际意义,某种情形当 ...

  3. LightOJ 1248 Dice (III) 概率

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

  4. hdu 4625 Dice(概率DP)

    Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submi ...

  5. hdu 4586 Play the Dice(概率dp)

    Problem Description There is a dice with n sides, which are numbered from 1,2,...,n and have the equ ...

  6. HihoCoder - 1339 Dice Possibility(概率dp)

    题意:求用N(1<=N<=100)个骰子掷出M(1<=M<=600)的概率 分析:直接求概率可能出现6^100次方,会爆精度.可以用一个数组dp[i][j]记录用i个骰子掷出j ...

  7. HihoCoder1339 Dice Possibility(概率DP+母函数)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is possibility of rolling N dice and the sum of the numb ...

  8. HDU 4652 Dice (概率DP)

    版权声明:欢迎关注我的博客,本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/36685493 D ...

  9. Throwing Dice(概率dp)

    C - Throwing Dice Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Lig ...

随机推荐

  1. 1 weekend110的hdfs源码跟踪之打开输入流 + hdfs源码跟踪之打开输入流总结

    3种形式的元数据,fsimage是在磁盘上,meta.data是在内存上, 我们继续,前面呢,断点是打在这一行代码处, FileSystem fs = FileSystem.get(conf); we ...

  2. Preferred Java way to ping a HTTP Url for availability

    I need a monitor class that regularly checks whether a given HTTP URL is available. I can take care ...

  3. hdoj 2063 过山车【匈牙利算法+邻接矩阵or邻接表】

    过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  4. SQL基础之 时间戳

    本文转载:http://www.cnblogs.com/liuhh/archive/2011/05/14/2046544.html 一直对时间戳这个概念比较模糊,相信有很多朋友也都会误认为:时间戳是一 ...

  5. Linux系统调优1

    Linux在进行系统调优的时候,首先要考虑整个操作系统的结构,然后针对各个部分进行优化,下面展示一个Linux系统的各个组成部分: 有上图可以看出,我们可以调整的有应用程序,库文件,内核,驱动,还有硬 ...

  6. qt 程序国际化

    http://www.cnblogs.com/hujian/archive/2012/08/10/2631488.html

  7. 使用Socket模拟一个简单的Webservice调用

    webservice是对socket的一个封装,让远程调用调用变得更加简单,那么使用socket究竟有多么麻烦呢?来看看. 做一个简单的天气查询: 服务端: public class SocketSe ...

  8. 百度地图BMap API实例

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  9. sqlmap

    http://192.168.136.131/sqlmap/mysql/get_int.php?id=1 当给sqlmap这么一个url的时候,它会: 1.判断可注入的参数 2.判断可以用那种SQL注 ...

  10. CI框架篇之预热篇(1)

    CodeIgniter 的基本都了解了,现在就开始预热,如果学习一门语言一样,我们最开始都是输出一个'HELLO WORLD'一样, 现在我们也通过输出这样一个内容,来了解基本的使用. CodeIgn ...