题意:求用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. C语言 函数指针二(正向调用)

    //函数指针做函数参数 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<Wi ...

  2. Django - 安装filebrowser发生Error finding Upload-Folder错误

    Error finding Upload-Folder (site.storage.location + site.directory). Maybe it does not exist? 解决: F ...

  3. 【BZOJ】3297: [USACO2011 Open]forgot(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3297 这题拖了很久呢... 很久以前写了个dfs,,但是tle了..... 然后一直想dp想不出来, ...

  4. ios 页面过长卡顿的情况

    解决方案如下: -webkit-overflow-scrolling: touch;

  5. (转)使用.NET Reflector 查看Unity引擎里面的DLL文件

    当你查看unity里面API的时候,是不是有时候追踪了一两步就碰到DLL文件走不下去了呢?很是不爽吧. 这种问题我也是经常碰到.这是人家商业引擎不想让你看到底层代码啦,所以着急不得. 不过,今天我终于 ...

  6. Django(模板语言-自定义filter和simple_tag)

    Django(模板语言-自定义filter和simple_tag)   filter过滤器的主要形式:变量|函数,意思是将变量交给函数处理,而自定义filter就是自己定义函数,因为用到已有的很少. ...

  7. sql case when then else end sql_variant

    /****************************************************************************** ** Name: usp_cfg_Get ...

  8. util.inherits

    util.inherits util.inherits(constructor, superConstructor)是一个实现对象间原型继承 的函数. JavaScript 的面向对象特性是基于原型的 ...

  9. Linux下tomcat相关操作

    tomcat安装: 直接到官网下载tar包解压即可. tomcat相关操作: 首先,进入Tomcat下的bin目录,例如:cd /usr/tomcat/bin 启动Tomcat:./startup.s ...

  10. JVM难学?那是因为你没认真看完这篇文章(转)

    一:虚拟机内存图解 JAVA程序运行与虚拟机之上,运行时需要内存空间.虚拟机执行JAVA程序的过程中会把它管理的内存划分为不同的数据区域方便管理. 虚拟机管理内存数据区域划分如下图: 数据区域分类: ...