A - QQpet exploratory park HDU - 1493 DP
determining the number of datasets. Then t lines follows. Each line
contains 6 numbers pi, i ∈{ 1, 2, …, 6 }, indicating the probability of
getting 1 to 6 after you toss the die every time . p1+ p2+ … + p6 = 1.
OutputFor each test case, output the probability of touching each
important grid. accurate up to 1 decimal places. There is a blank line
between test cases. See the Sample Output to get the exactly output
format.
Sample Input
2
0.000 1.000 0.000 0.000 0.000 0.000
0.500 0.000 0.000 0.000 0.000 0.500
Sample Output
5: 0.0%
12: 100.0%
22: 0.0%
29: 0.0%
33: 0.0%
38: 0.0%
42: 0.0%
46: 0.0%
50: 0.0%
55: 0.0% 5: 3.1%
12: 30.5%
22: 27.3%
29: 24.6%
33: 21.9%
38: 10.9%
42: 0.8%
46: 0.0%
50: 4.4%
55: 1.0% OJ-ID:
HDU-1493 author:
Caution_X date of submission:
20190930 tags:
概率DP description modelling:
投掷10次骰子,掷出的点数概率已给出,问掷完后落在5, 12, 22, 29, 33, 38, 42, 46, 50 55点上的概率。 major steps to solve it:
1.dp[i][j]:=第j次投在第i格上的概率,p[]:=各个点的概率
2.dp[i][1]=p[i];
3.dp[i+k][j+1]+=dp[i][j]*p[k]; AC CODE:
#include<bits/stdc++.h>
using namespace std;
double p[];
double dp[][];
int a[]={,,,,,,,,,};
int main()
{
//freopen("input.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--) { for(int i=; i<=; i++) {
scanf("%lf",&p[i]);
} memset(dp,,sizeof(dp));
for(int i=;i<=;i++){
dp[i][]=p[i];
} for(int j=; j<=; j++) {
for(int i=; i<=; i++) {
for(int k=; k<=; k++) {
dp[i+k][j+]+=dp[i][j]*p[k];
}
}
} for(int i=; i<; i++) {
double ans=;
for(int j=;j<=;j++){
ans+=dp[a[i]][j];
}
printf("%d: %.1f%%\n",a[i],ans*);
}
if(t) printf("\n"); }
return ;
}
A - QQpet exploratory park HDU - 1493 DP的更多相关文章
- Q - QQpet exploratory park HDU - 1493 (概率DP)
题目大意: 一共有61个位置,标记为0~60.其中有10个重要位置,分别为:5, 12, 22, 29, 33, 38, 42, 46, 50 and 55. 有一个筛子,一共6个面,标有1~6.摇到 ...
- QQpet exploratory park(DP)
QQpet exploratory park Today, more and more people begin to raise a QQpet. You can get a lot of plea ...
- 【HDOJ】1493 QQpet exploratory park
超水的动态规划.最后要对概率求Sigma. #include <cstdio> #include <cstring> #include <cstdlib> #def ...
- hdu 3016 dp+线段树
Man Down Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- HDU 5928 DP 凸包graham
给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...
- HDU 1069 dp最长递增子序列
B - Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- HDU 1160 DP最长子序列
G - FatMouse's Speed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- hdu 4826(dp + 记忆化搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...
- HDU 2861 (DP+打表)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2861 题目大意:n个位置,m个人,分成k段,统计分法.S(n)=∑nk=0CknFibonacci(k ...
随机推荐
- Vue修改单个组件的背景颜色
组件默认背景颜色为白色,但工作需要改成黑色,于是研究了一番. 很简单,只需在组件中使用两个钩子函数beforeCreate (),beforeDestroy () 代码如下: beforeCreate ...
- 常见跨域解决方案以及Ocelot 跨域配置
常见跨域解决方案以及Ocelot 跨域配置 Intro 我们在使用前后端分离的模式进行开发的时候,如果前端项目和api项目不是一个域名下往往会有跨域问题.今天来介绍一下我们在Ocelot网关配置的跨域 ...
- CNN反向传播更新权值
背景 反向传播(Backpropagation)是训练神经网络最通用的方法之一,网上有许多文章尝试解释反向传播是如何工作的,但是很少有包括真实数字的例子,这篇博文尝试通过离散的数据解释它是怎样工作的. ...
- wpf button style IsMouseOver
<Style x:Key="workButtonStyle" TargetType="{x:Type Button}"> <Style.Tri ...
- .NET MVC5简介(三)Result
Ajax请求数据响应格式,一个醒目组必须是同意的,前端才知道怎么应付,还有很多其他情况,比如异常了,有ExceptionFilter,按照固定格式返回,比如没有权限,Authorization,按照固 ...
- 深入理解AbstractQueuedSynchronizer(AQS)
本人免费整理了Java高级资料,涵盖了Java.Redis.MongoDB.MySQL.Zookeeper.Spring Cloud.Dubbo高并发分布式等教程,一共30G,需要自己领取.传送门:h ...
- Vue中v-on的指令以及一些其他指令
1.v-on的基本使用 <div id="app"> <!-- 使用事件绑定的简写形式 --> <input type="button&qu ...
- JAVA 设置模块间的依赖关系
项目目录概况 Demo01项目 Test01.java package com.sam.demo01; public class Test01 { public void ShowTest01() { ...
- css 关于浮动float的使用以及清除浮动
float:none | left | right 默认值:none 适用于:所有元素 none:设置对象不浮动left:设置对象浮在左边right:设置对象浮在右边 当该属性不等于none引起对象浮 ...
- jquery-uploadfile的使用(多文件异步上传)
需求 在页面端可以在页面不刷新情况下上传多个有大小限制的word文件,并返回文件保存的路径,同时可以删除误上传的文件. 准备 下载该插件 该插件依赖jquery1.9.1版本(其它不清楚)*在jsp页 ...