Dice Possibility
Dice Possibility
描述
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的更多相关文章
- HihoCoder1339 Dice Possibility(概率DP+母函数)
		时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is possibility of rolling N dice and the sum of the numb ... 
- hihoCoder 1339 Dice Possibility(DP)
		http://hihocoder.com/problemset/problem/1339 题意: 求一个骰子扔n次后最后点数相加为m的概率. 思路: f[i][j]表示扔到第i次时总值为j的概率. # ... 
- HihoCoder - 1339 Dice Possibility(概率dp)
		题意:求用N(1<=N<=100)个骰子掷出M(1<=M<=600)的概率 分析:直接求概率可能出现6^100次方,会爆精度.可以用一个数组dp[i][j]记录用i个骰子掷出j ... 
- hiho一下 第174周
		题目1 : Dice Possibility 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is possibility of rolling N dice ... 
- hdu 4586 Play the Dice     概率推导题
		A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ... 
- HDU 4586 A - Play the Dice 找规律
		A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ... 
- 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 ... 
- HDU 4586 Play the Dice(数学期望)
		Play the Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tot ... 
- hdu 4586 Play the Dice (概率+等比数列)
		Play the Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) To ... 
随机推荐
- Redis简介一
			Redis是一个开源的,使用C语言编写,面向“键/值”对类型数据的分布式NoSQL数据库系统,特点是高性能,持久存储,适应高并发的应用场景.Redis纯粹为应用而产生,它是一个高性能的key-valu ... 
- gson学习以及进阶文章推荐
			Json转换利器Gson之实例一-简单对象转化和带泛型的List转化 (http://blog.csdn.net/lk_blog/article/details/7685169)Json转换利器Gso ... 
- Android Studio 项目结构
			在Android Studio中创建项目后,会出现 activity_main.xml 和 MainActivity.java 两个文件 其中 Java文件定义了一个Activity,当应用运行时, ... 
- Apriori算法-java
			package com.yang; import java.util.*; public class Apriori { private double minsup = 0.2;// 最小支持度 ... 
- nfs服务器的建立
			NFS服务器的配置 一.NFS服务器端的配置,即共享发布者 (一)需启动的服务和需安装的软件 1.NFS服务器必须启动两个daemons服务:rpc.nfsd和rpc.mountd rpc.nfs ... 
- 授权给指定用户,使用navicat在其他ip都可以连接linux服务器上的mysql库
			grant all privileges on ao.* to 'tony'@'localhost' identified by '123456'; 在ao库中所有表. 同意 ,授权 给ton ... 
- const放在函数前和函数后
			class c { public: returnType functionName (parameter list) const; //这个函数不会修改类成员 const returnType fun ... 
- think in uml-关系
			1.关联关系association 在一段时间内将多个类的实例连接在一起 某个对象在一段时间内一直"知道"另一个对象的存在 2.依赖关系dependency 一个对象的修改会导致另 ... 
- docker installation on ubuntu
			Ubuntu Docker is supported on these Ubuntu operating systems: Ubuntu Xenial 16.04 (LTS) Ubuntu Trust ... 
- 转 Oracle DBCA高级玩法:从模板选择、脚本调用到多租户
			但凡是学过Oracle的同学,对DBCA(Database Configuration Assistant, DBCA)都不会陌生,有了这个工具,使得创建数据库成为可能.而DBCA本身有图形和静默两种 ... 
