题目1 : 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<stdio.h>
#include<string.h>
#include<stdlib.h>
double dp[][];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n, m;
scanf("%d%d", &n, &m);
memset(dp, , sizeof(dp));
for (int i = ; i <= ; i++) {
dp[][i] = 1.0 / 6.0;
}
for (int i = ; i <= n; i++) {
for (int j = i; j <= * i; j++) {
double tmp = ;
for (int k = ; k <= ; k++) {
tmp += dp[i - ][j - k];
}
tmp /= 6.0;
dp[i][j] = tmp;
}
}
printf("%.2lf\n", dp[n][m] * );
return ;
}

最新文章

  1. SQL Server performance tips
  2. 【C语言】C语言常量和变量
  3. 048医疗项目-模块四:采购单模块—采购单受理(Dao,Service,Action三层)
  4. iOS推送处理
  5. VPS常用工具
  6. rtc关机闹钟4 AlarmManagerService.java
  7. (function($){...})(jQuery)是什么意思
  8. 【M18】分期摊还预期的计算成本
  9. dataStructure@ Find if there is a path between two vertices in a directed graph
  10. FileInputStreamTest
  11. 基于.NET CORE微服务框架 -surging 基于messagepack、protobuffer、json.net 性能对比
  12. Javascript介绍(了解)
  13. [物理学与PDEs]第2章第2节 粘性流体力学方程组 2.3 广义 Newton 法则---本构方程
  14. tp5.1的安装与运行流程
  15. 当强制关机时,出现Eclipse打不开的问题
  16. mac 安装geckodriver和chromedriver
  17. hdu 5120 Intersection 两个圆的面积交
  18. 基于WMI的信息查询和编辑,按微软的说明一般都是
  19. IntelliJ IDEA 2017版 编译器使用学习笔记(六) (图文详尽版);IDE快捷键使用
  20. mysql学习------错误日志和通用查询日志

热门文章

  1. 重新理解 Monad
  2. angular搭建
  3. 【剑指Offer】14、链表中倒数第k个结点
  4. ext4的一些特性
  5. [NOIP2018模拟赛]d
  6. 最佳实践 | 源码升级gcc
  7. poj 1274 基础二分最大匹配
  8. mongodb--group聚合运算
  9. codevs——T2894 Txx考试
  10. Apache vs. Nginx