Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet exploratory park in the world. Every week, you can get a chance to have a joy there for free. The whole park contains 61 grids in a line, numbered from 0 to 60. Ten of them are important grids which will touch off ( 引发 ) an incident when the pet stands on. They are 5, 12, 22, 29, 33, 38, 42, 46, 50 and 55. Your pet is standing on the gird of number 0 in the beginning. You can toss the die ( 掷骰子 ) 10 times. Each time, the pet goes ahead n steps which n is the number from the die ( n ∈{ 1, 2, …, 6 } ). If your RP is great enough( calls RPG for short ), you will get many surprises in the important grids, such as some yuanbao( the money in QQpet world ), an improvement of your pet's ability, and the most attractive gift-package. Now, your task is to calculate the probability(概率) of touching each important grid.

InputThe first line of the input contains an integer t–
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的更多相关文章

  1. 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.摇到 ...

  2. QQpet exploratory park(DP)

    QQpet exploratory park Today, more and more people begin to raise a QQpet. You can get a lot of plea ...

  3. 【HDOJ】1493 QQpet exploratory park

    超水的动态规划.最后要对概率求Sigma. #include <cstdio> #include <cstring> #include <cstdlib> #def ...

  4. hdu 3016 dp+线段树

    Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  5. HDU 5928 DP 凸包graham

    给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...

  6. HDU 1069 dp最长递增子序列

    B - Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  7. HDU 1160 DP最长子序列

    G - FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  8. hdu 4826(dp + 记忆化搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...

  9. HDU 2861 (DP+打表)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2861 题目大意:n个位置,m个人,分成k段,统计分法.S(n)=∑nk=0CknFibonacci(k ...

随机推荐

  1. php laravel请求处理管道(装饰者模式)

    laravel的中间件使用了装饰者模式.比如,验证维护模式,cookie加密,开启会话等等.这些处理有些在响应前,有些在响应之后,使用装饰者模式动态减少或增加功能,使得框架可扩展性大大增强. 接下来简 ...

  2. html的特殊符号对照表

    HTML的特殊符号对照表. 特殊符号 命名实体 十进制编码 特殊符号 命名实体 十进制编码 特殊符号 命名实体 十进制编码 Α Α Α Β Β Β Γ Γ Γ Δ Δ Δ Ε Ε Ε Ζ Ζ Ζ Η ...

  3. java自适应响应式 企业网站源码 SSM freemaker生成静态化 手机 平板 PC springmvc

    java 企业网站源码 前后台都有 静态模版引擎, 代码生成器大大提高开发效率 前台: 支持两套模版, 可以在后台切换 系统介绍: 1.网站后台采用主流的 SSM 框架 jsp JSTL,网站后台采用 ...

  4. Vue--过滤器、指令、插件

    常用下载js的网址: https://www.bootcdn.cn/ https://www.jsdelivr.com/ 一.过滤器 vue 允许自定义过滤器,用于格式化一些常见文本(如日期等). 1 ...

  5. centos7 apache后台转nginx后台

    背景 一开始买完服务器装的是用apache搭的后台, 现在想使用nginx, 希望对你有参考作用 查看系统版本信息 lsb_release -a 我的版本信息是 首先关闭apache-tomcat服务 ...

  6. 查找发布地图的 REST URL并查询相关信息

    1.登录ArcGIS Server Manager 2.登录后,里面是以前自己发布的地图服务 3.点击自己发布的地图,然后按下功能选项,再点击箭头来找到URL 4.点击进去,分别能从红圈中找到相关的信 ...

  7. linux软件管理-RPM

    目录 linux软件管理-RPM RPM的基础概述 RPM包安装管理 linux软件管理-RPM RPM的基础概述 rpm:RPM全称RPM Package Manager缩写,由红帽开发用于软件包的 ...

  8. [20190524]sqlplus 与输出&.txt

    [20190524]sqlplus 与输出&.txt --//在sqlplus下 &一般作为参数替换,如何要输出&,一般有几种情况.据说这个问题是asktom站点查看最多的问题 ...

  9. PyCharm彻底删除项目

    直接删除源文件,删不干净,会留下一些文件 1.点击File,选择Close Project 2.关闭项目之后,会弹出一个选择项目的界面,点击你想要删除的项目右边的叉 3.然后找到该项目所在的路径,选中 ...

  10. Ubuntu 根目录作用

    Ubuntu的根目录下存在着很多的文件夹,但你知道他们都存放着哪些文件呢?这些是深入了解Ubuntu系统必不缺少的知识,本文就关于此做一下介绍吧. /bin/    用以存储二进制可执行命令文件,/u ...