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. Algorithm: Prime & Euler Function & Productive Function

    素数筛 朴素算法 一般来说,可以用试除法判断某一个数是不是素数: bool isPrime(int n) { if(n < 2) return false; for(int i = 2; i & ...

  2. gcc原子操作测试

    #include <stdio.h> #include <pthread.h> #include <stdlib.h> ; void *test_func(void ...

  3. 记一次收集APP native崩溃信息

    最近在学习 极客时间Android开发高手课 老师推荐了Breakpad开源库来采集native 的crash1.为什么要使用Google Breakpad? 我们在开发过程中,Android JNI ...

  4. 【HDU6037】Expectation Division(动态规划,搜索)

    [HDU6037]Expectation Division(动态规划,搜索) 题面 Vjudge 你有一个数\(n\),\(n\le 10^{24}\),为了方便会告诉你\(n\)分解之后有\(m\) ...

  5. Java8的Stream方法findAny空指针异常(NullPointerException)实例对比

    实战介绍 学习完Java8的Stream方法,可能你正准备大展身手,却发现遇到不少问题,本篇文章为大家带来一个findAny方法抛出java.lang.NullPointerException的场景. ...

  6. cl_demo_output=>display 介绍

    Methods of CL_DEMO_OUTPUT PS:自己测试是display后的内表不能带表头. 类CL_DEMO_OUTPUT 在示例程序中创造了很多简单的数据输出的方法而不需要经典的list ...

  7. 如何访问到静态的文件,如jpg,js,css.

    如果你的DispatcherServlet拦截"*.do"这样的有后缀的URL,就不存在访问不到静态资源的问题. 如果你的DispatcherServlet拦截"/&qu ...

  8. 创建Npm脚手架

    1工具 l  Npm ( https://nodejs.org/en/ ) l  Yeoman (npm install -g yo) l  generator-generator (npm inst ...

  9. Android框架Volley使用:Post请求实现

    首先我们在项目中导入这个框架: implementation 'com.mcxiaoke.volley:library:1.0.19' 在AndroidManifest文件当中添加网络权限: < ...

  10. [20190531]建立job与commit.txt

    [20190531]建立job与commit.txt --//昨天看链接:https://connor-mcdonald.com/2019/05/28/dbms_job-the-joy-of-tran ...