题意:求用N(1<=N<=100)个骰子掷出M(1<=M<=600)的概率

分析:直接求概率可能出现6^100次方,会爆精度。可以用一个数组dp[i][j]记录用i个骰子掷出j的概率。i为0时无论j是多少,概率都是0。i为1时,j从1-6的概率都是1/6。其余可以递推得到

dp[i][j]  = 0 (j<i || j>6*i),sigma(dp[i-1][max(0,j-k)])  (1<=k<=6)

#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int maxn = 1e4+;
const int INF= 0x3f3f3f3F;
const int mod = ;
double dp[][];
void pre()
{
for(int i=;i<=;++i) dp[][i]=(double)(1.0/);
for(int i=;i<=;++i){
for(int j=;j<=;++j){
if(j<i) dp[i][j] = 0.0;
else{
dp[i][j] =;
for(int k=max(,j-);k<j;++k){
dp[i][j] += 1.0*dp[i-][k]/6.0;
}
}
}
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
dp[][]=;
pre();
int T,N,M,Q,u,v,tmp,K;
while(scanf("%d%d",&N,&M)==){
printf("%.2f\n",100.0*dp[N][M]);
}
return ;
}

HihoCoder - 1339 Dice Possibility(概率dp)的更多相关文章

  1. hihoCoder 1339 Dice Possibility(DP)

    http://hihocoder.com/problemset/problem/1339 题意: 求一个骰子扔n次后最后点数相加为m的概率. 思路: f[i][j]表示扔到第i次时总值为j的概率. # ...

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

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

  3. dice 概率论 概率DP

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

  4. 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 ...

  5. hdu 4625 Dice(概率DP)

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

  6. HDU 4652 Dice (概率DP)

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

  7. Dice (III) 概率dp

    #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> ...

  8. Throwing Dice(概率dp)

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

  9. HDU 4599 Dice (概率DP+数学+快速幂)

    题意:给定三个表达式,问你求出最小的m1,m2,满足G(m1) >= F(n), G(m2) >= G(n). 析:这个题是一个概率DP,但是并没有那么简单,运算过程很麻烦. 先分析F(n ...

随机推荐

  1. RMAN Restore, Recovery

    Complete recovery: rman target / nocatalog startup mount; restore database; recover database; alter ...

  2. Windows动态库的使用 part one

    二.动态库程序 这篇写得比较乱,看不懂的可以跳part 2,直接上图片的.   动态库的使用: 4.3.1 隐式链接 动态库的隐式连接,需要动态库的 动态库文件".dll" , 动 ...

  3. 扩张js的String——trim

    //去掉字符两端的空白字符  String.prototype.Trim=function () {      return this.replace(/(^[\t\n\r]*)|([\t\n\r]* ...

  4. jquery图片上传前预览剪裁

    http://www.webmotionuk.co.uk/jquery/image_upload_crop.php http://keleyi.com/a/bjad/liuvpkke.htm 不错的d ...

  5. 几个比较经典的算法问题的java实现

    1.八皇后问题 public class EightQueen { private static final int ROW = 16; private static final int COL = ...

  6. 对Linux命令进一步学习vim(二)

    今天,进一步学习Linux相关的命令,可能会有重复的地方,但学习本来就是不断重复的过程.故作小记! 1.安装了:vim  ,,,一款Linux爱好者经常用到的ide sudo apt-get inst ...

  7. 【转】SetThreadLocale解决越南文乱码问题

    转自http://hi.baidu.com/killwolf110/item/838d56224067c63395f62b70 程序需要运行在越南地区,语言为越南文,操作系统为英文版,程序支持unic ...

  8. WPF数据验证(4)——响应与获取验证错误

    1780 前面的示例中,有关用户接受到错误的唯一指示是在违反规则的文本框周围的红色轮廓.为了提供更多信息,可以处理 Error 事件,但存储或清除错误时会引发该事件,但前提是必须确保已将 Bindin ...

  9. poj 3422(最小费用最大流)

    题目链接:http://poj.org/problem?id=3422 思路:求从起点到终点走k次获得的最大值,最小费用最大流的应用:将点权转化为边权,需要拆点,边容量为1,费用为该点的点权,表示该点 ...

  10. 在UI线程之外,多线程处理Bitmaps

    多线程处理Bitmaps     上一篇,我们讨论了:Android有效的处理Bitmap,降低内存 ,可是最好不要运行在主线程(UI线程),假设图片是本地的或者网络的又或者是其它地方的. 图片载入的 ...