题意:求用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. Jmeter负载测试例子

    通过浏览器操作网站在jmeter录屏控制器显示录屏例子,并且通过这例子模拟多用户(线程)来负载测试. 工具/原料   Jmeter 浏览器 1.先在测试计划创建线程组和录制Case   1 1.1 选 ...

  2. 第二百二十节,jQuery EasyUI,Slider(滑动条)组件

    jQuery EasyUI,Slider(滑动条)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 Slider(滑动条)组件的使用方法,这个 ...

  3. mfc小工具开发之定时闹钟之---功能介绍

    使用背景: 之前在xp上用过飞雪日历,感觉挺好用的,还有在音频上的兴趣,促使了我也要自己做一个简单的定时闹钟. 之前开发过图片格式的小工具,没来的急分享,后期整理后,一块奉上,写这篇介绍的时候已近完成 ...

  4. CSS:层叠样式表的冲突处理

    前言 重叠样式表的冲突是通过重叠过程排序,最终确定文档的显示方式的,也就是是说通过重叠排序来处理冲突问题.这过程起决定性作用的是选择器及其相关申明的特殊性,以及继承机制. 基本流程 1.找出所有相关规 ...

  5. java-web 过滤器 &amp; 监听器 &amp; 拦截器

    Tomcat 的容器分为四个等级.真正管理 Servlet 的容器是 Context 容器,一个 Context 对应一个 Web 工程.在 Tomcat 的配置文件里能够非常easy发现这一点.例如 ...

  6. linux机器之间配置ssh无密访问

    首先确认已安装了ssh服务,没装的自行百度一下. A机器:192.168.1.1 B机器:192.168.1.2 使A无密访问B,步骤如下[root@localhost ~]# cd .ssh 如果没 ...

  7. 如何下载ubuntu桌面,并使用

    下载ubuntu,进行linux系统的操作 1.下载ubuntu 百度搜索ubuntu或直达下载链接http://cn.ubuntu.com/download/ 你可以选择,优麒麟16或者Ubuntu ...

  8. redis问题集

    Redis有哪些数据结构? 字符串String.字典Hash.列表List.集合Set.有序集合SortedSet. 如果你是Redis中高级用户,还需要加上下面几种数据结构HyperLogLog.G ...

  9. UITabBarItem如何更改高度

    本文转载至 http://www.cocoachina.com/bbs/read.php?tid=255361 我目前有个UITabBar,改了它的高度.但是我切换页签后,这个UITabBar样式又变 ...

  10. SQL Server 2008 R2 开启远程连接

    因为sql server 2008默认是不允许远程连接的,sa帐户也是默认禁用的,如果想要在本地用SSMS(SQL Server Management Studio Express) 连接远程服务器上 ...