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