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 ...
随机推荐
- Algorithm: Prime & Euler Function & Productive Function
素数筛 朴素算法 一般来说,可以用试除法判断某一个数是不是素数: bool isPrime(int n) { if(n < 2) return false; for(int i = 2; i & ...
- gcc原子操作测试
#include <stdio.h> #include <pthread.h> #include <stdlib.h> ; void *test_func(void ...
- 记一次收集APP native崩溃信息
最近在学习 极客时间Android开发高手课 老师推荐了Breakpad开源库来采集native 的crash1.为什么要使用Google Breakpad? 我们在开发过程中,Android JNI ...
- 【HDU6037】Expectation Division(动态规划,搜索)
[HDU6037]Expectation Division(动态规划,搜索) 题面 Vjudge 你有一个数\(n\),\(n\le 10^{24}\),为了方便会告诉你\(n\)分解之后有\(m\) ...
- Java8的Stream方法findAny空指针异常(NullPointerException)实例对比
实战介绍 学习完Java8的Stream方法,可能你正准备大展身手,却发现遇到不少问题,本篇文章为大家带来一个findAny方法抛出java.lang.NullPointerException的场景. ...
- cl_demo_output=>display 介绍
Methods of CL_DEMO_OUTPUT PS:自己测试是display后的内表不能带表头. 类CL_DEMO_OUTPUT 在示例程序中创造了很多简单的数据输出的方法而不需要经典的list ...
- 如何访问到静态的文件,如jpg,js,css.
如果你的DispatcherServlet拦截"*.do"这样的有后缀的URL,就不存在访问不到静态资源的问题. 如果你的DispatcherServlet拦截"/&qu ...
- 创建Npm脚手架
1工具 l Npm ( https://nodejs.org/en/ ) l Yeoman (npm install -g yo) l generator-generator (npm inst ...
- Android框架Volley使用:Post请求实现
首先我们在项目中导入这个框架: implementation 'com.mcxiaoke.volley:library:1.0.19' 在AndroidManifest文件当中添加网络权限: < ...
- [20190531]建立job与commit.txt
[20190531]建立job与commit.txt --//昨天看链接:https://connor-mcdonald.com/2019/05/28/dbms_job-the-joy-of-tran ...