题意:求用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. 请说明meta标签的作用。

    请说明meta标签的作用. 解答: meta是用来在HTML文档中模拟HTTP协议的响应头报文.meta 标签用于网页的<head>与</head>中,meta 标签的用处很多 ...

  2. 获取一个Assembly中的命名空间列表

    通过System.Reflection.Assembly类中提供的方法和属性不能直接获取组件中的命名空间列表.但有方法可以直接获得Assembly中的所有类型,我们便可以通过获取的类型来得到命名空间名 ...

  3. 2018 CCPC 桂林游记

    TYPE: Onsite Contest NAME: 2018 - CCPC - Guilin PLAT: HUSTOJ TIME: 2018/10/28 09:00-14:00 CST LOCA: ...

  4. IOS7--javascriptcore中jscontext使用要注意的一点

    在公司一个项目中,用到了highchart做图表显示的组件,这就要用到了javascriptcore,代码就不上了,说说原理. 需求是这样的,通过http请求server csv格式的数据,然后解析, ...

  5. HDU 5894 hannnnah_j’s Biological Test

    题目链接:传送门 题目大意:有n张板凳围成一圈,有m个人,要让m个人都坐到凳子上且任意两人之间相隔>=k 个凳子,问有多少种方法%(1e9+7) 题目思路:组合数学 我们这样考虑,既然每个人相距 ...

  6. JAVA 集合相关整理和学习

    一.Set接口实现类 二.List接口实现类 三.Queue接口实现类 四.Map接口实现类 五.上面的图片截自附件: 附件列表

  7. Linux磁盘分区的理解

    磁盘分割: 一块磁盘可以被分割为多个分区artition. 磁盘链接的方式 正常的实体机使用的都是/dev/sd[a-]的硬盘档名 虚拟机可能会使用/dev/vd[a-p]这种装置档名 SATA/US ...

  8. 编译型 解释型 C++工作原理

    C++教程_w3cschool https://www.w3cschool.cn/cpp/ C++工作原理: C++语言的程序因为要体现高性能,所以都是编译型的.但其开发环境,为了方便测试,将调试环境 ...

  9. Backtracking is a form of recursion.

    w https://www.cis.upenn.edu/~matuszek/cit594-2012/Pages/backtracking.html Starting at Root, your opt ...

  10. 百度 url 当在baidu搜索结果展示页,去点击标头时

    Spencer : 百度加一层跳转主要为了监控点击 w 基于dns和用户体验考虑的猜测 0-百度自己的cdn服务器存入各个域名/url的服务器ip(多ip情况下,返回物理空间相对用户最近的服务器ip) ...