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. [01]从零开始学 ASP.NET Core 与 EntityFramework Core 课程介绍

    从零开始学 ASP.NET Core 与 EntityFramework Core 课程介绍 本文作者:梁桐铭- 微软最有价值专家(Microsoft MVP) 文章会随着版本进行更新,关注我获取最新 ...

  2. Springmvc配置定时任务注解开发

    1.添加命名空间和xsd约束 xmlns:task="http://www.springframework.org/schema/task" http://www.springfr ...

  3. 前端之json,ajax和jsonp

    json json是 JavaScript Object Notation 的首字母缩写,单词的意思是javascript对象表示法,这里说的json指的是类似于javascript对象的一种数据格式 ...

  4. C#数组1

    using System; namespace ConsoleApp3 { class Program { static void Main(string[] args) { , , , , , }; ...

  5. C# - WinFrm应用程序MessageBox自动关闭小实验

    概述 在程序中MessageBox弹出的对话框,用于向用户展示消息,这是一个模式窗口,可阻止应用程序中的其他操作,直到用户将其关闭.但是有时候在自动化程序中,如果弹出对话框,程序将会中断,等待人工的干 ...

  6. python3之猜数字游戏

    猜数字小游戏 # coding:utf-8 import random #利用random生成一个1-10的随机数 luckeyNum = random.randint(1,10) #限定猜的次数 l ...

  7. 详细设计文档(final)

    1. 引言 1.1编写目的 本部分旨在阐明编写详细设计的目的,面向读者对象. 本文档主要描述各个模块的细节设计,明确软件的结构与实现过程,分析各个模块,描述模块的功能.性能和结构等方面包括模块接口.调 ...

  8. LInkHashMap源码分析

    说LinkHashMap之前,我们先来谈谈什么是LRU算法? 按照英文的直接原义就是Least Recently Used,最近最久未使用法,它是按照一个非常注明的计算机操作系统基础理论得来的:最近使 ...

  9. 通过GL函数处理图片以及其它相关功能

    我们知道在屏幕后处理里面通过 Graphics.Blit 函数可以通过材质处理屏幕图片, 当我们想要处理一般图片的时候, 直接调用GL函数就行了, 按照习惯自己封装一个 Blit 方法 : ) { i ...

  10. post 登录禅道,不成功,无解中

    ]}s.get("http://localhost/zentaopms116/www/misc-checkUpdate-16dd7448451f46bb496a2099b6a9af8c.ht ...