Dice Possibility

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

What is possibility of rolling N dice and the sum of the numbers equals to M?

输入

Two integers N and M. (1 ≤ N ≤ 100, 1 ≤ M ≤ 600)

输出

Output the possibility in percentage with 2 decimal places.

样例输入
2 10
样例输出
8.33
分析:依次枚举骰子;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e3+;
const int dis[][]={,,-,,,-,,};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m;
double dp[maxn][maxn];
int main()
{
int i,j,k,t;
scanf("%d%d",&n,&m);
rep(i,,)dp[][i]=1.0/;
rep(i,,n)
{
rep(j,,m)rep(k,,)
if(j-k>)dp[i][j]+=dp[i-][j-k]/;
}
printf("%.2f\n",dp[n][m]*);
//system("pause");
return ;
}

Dice Possibility的更多相关文章

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

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

  2. hihoCoder 1339 Dice Possibility(DP)

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

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

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

  4. hiho一下 第174周

    题目1 : Dice Possibility 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is possibility of rolling N dice ...

  5. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  6. HDU 4586 A - Play the Dice 找规律

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

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

  8. HDU 4586 Play the Dice(数学期望)

    Play the Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

  9. hdu 4586 Play the Dice (概率+等比数列)

    Play the Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) To ...

随机推荐

  1. UpdateData使用说明

    UpdateData() MFC的窗口函数,下面是MSDN的说明: Call this member function to initialize data in a dialog box, or t ...

  2. js第一天 innerHTML和value 的区别

    innerHTML在JS是双向功能:获取对象的内容 或 向对象插入内容:如:<div id="aa">这是内容</div> ,我们可以通过 document ...

  3. CSS3秘笈:第十一章

    表格和表单的格式化 1.表格的各种标签提供了许多有用的“钩子”,可以再上面挂CSS样式.如果创建了<th>标签样式,那么每一个列的标题——<th>标签——看起来就有可能与其他的 ...

  4. CSS3秘笈:第七章

    第七章  margin.padding和border 1.盒模型:四个属性: (1)padding:内容与其边框线之间的空间. (2)border:盒子周围的直线 (3)background-colo ...

  5. 十一章:用CSS进行布局

    本章重点:盒模型与元素浮动. 盒模型: 1.CSS处理网页时,它认为每个元素都包含在一个不可见的盒子里.这就是众所周知的盒模型,这里的盒子由内容区域.内容区域周围的空间.内边距和外边缘和边框外面将元素 ...

  6. css字体设置

    css字体设置 .selector{ font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,S ...

  7. A框架第一步,传递不同参数.主程序执行对应方法

    访问: www.test.com/admin 1============后台目录:admin (确保单一入口) --有入口文件index.php <?phprequire '../A/a.php ...

  8. HDU1686:Oulipo

    Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...

  9. 数据库NULL和 ‘’ 区别

    NULL判断时 : IS NOT NULL ''判断时: !=''

  10. jetty访问jsp页面出现( PWC6345: There is an error in invoking javac)

    org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac.  A full JDK (not ju ...