QQpet exploratory park

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�C 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% //题意:第一行测试组数 T ,然后给出掷骰子出现 1 2 3 4 5 6 的概率,问到达指定位置的概率是多少?
简单概率dp
 #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std; double dp[][]; // i 次到 j 的概率
double p[];
double a[]; int main()
{
int T;
cin>>T;
while (T--)
{
for (int i=;i<=;i++)
scanf("%lf",&p[i]);
memset(dp,,sizeof(dp));
memset(a,,sizeof(a));
for (int i=;i<=;i++) dp[][i]=p[i];
for (int i=;i<=;i++)
{
for (int j=;j<=;j++)
{
for (int k=;k<=;k++)
if (j-k>=)
dp[i][j]+=dp[i-][j-k]*p[k];
}
}
for(int i=;i>;i--) a[]+=dp[i][]; printf("5: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("12: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("22: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("29: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("33: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("38: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("42: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("46: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("50: %.1lf%%\n",a[]*);
for(int i=;i>;i--) a[]+=dp[i][]; printf("55: %.1lf%%\n",a[]*);
if (T) cout<<endl;
}
return ;
}

QQpet exploratory park(DP)的更多相关文章

  1. A - QQpet exploratory park HDU - 1493 DP

      A - QQpet exploratory park HDU - 1493 Today, more and more people begin to raise a QQpet. You can ...

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

  3. 【HDOJ】1493 QQpet exploratory park

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

  4. HDU 4607 Park Visit (DP最长链)

    [题目]题意:N个城市形成一棵树,相邻城市之间的距离是1,问访问K个城市的最短路程是多少,共有M次询问(1 <= N, M <= 100000, 1 <= K <= N). [ ...

  5. HDU-4607 Park Visit bfs | DP | dfs

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607 首先考虑找一条最长链长度k,如果m<=k+1,那么答案就是m.如果m>k+1,那么最 ...

  6. [CSP-S模拟测试]:Park(树上DP)

    题目描述 公园里有$n$个雕像,有$n-1$条道路分别连接其中两个雕像,任意两个雕像可以直接或间接相连.现在每个景点$i$聚集着$P_i$只鸽子,旅行家手里有$v$数量的面包屑. 一旦旅行家在雕像$i ...

  7. Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)

    题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...

  8. Codeforces Round #369 (Div. 2) C. Coloring Trees DP

    C. Coloring Trees   ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the pa ...

  9. C. Coloring Trees DP

    传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 secon ...

随机推荐

  1. python pep8编码风格学习记录(转)

    简要归纳 每个缩进层级使用4个空格. 每行最多79个字符. 顶层的函数或类的定义之间空两行. 采用ASCII或UTF-8编码文件 在文件顶端,注释和文档说明之下,每行每条import语句只导入一个模块 ...

  2. StringBuilder.append()与String的"+"的效率PK

    如果String通过"+"来拼接,如果拼接的字符串是常量,则效率会非常高,因为会进行编译时优化,这个时候StringBuilder的append()是达不到的. 如果将String ...

  3. elasticsearch 安装和部署

    jdk要用1.8以上(elasticsearch版本是1.7.3) 下载elasticsearch的tar包,解压开,更改其名称  mv elasticsearch-5.x.x elasticsear ...

  4. Jenkins 安装卡住不动的解决方案

    如果在安装jenkins时卡在getting startted的界面,如下所示 jenkins在安装插件前总是尝试连接www.google.com,来判断网络是否连通.谷歌的网站在大陆是连不上的,所以 ...

  5. JS杂技之无中间变量的值交换方式

    从http://www.cnblogs.com/liuyitian/p/4081517.html#3074553看到一种无中间变量的值交换方式,具体如下: var a = 1;var b = 2;a ...

  6. POJ 2388:Who&#39;s in the Middle

    Who's in the Middle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31015   Accepted: 1 ...

  7. 使用Batik绘制SVG图并保存为png图像格式

    SVG(Scalable Vector Graph)--可缩放矢量图形. 可缩放矢量图形是基于可扩展标记语言(标准通用标记语言的子集),用于描写叙述二维矢量图形的一种图形格式.它由万维网联盟制定.是一 ...

  8. 随想录(做自己代码的測试project师)

    [ 声明:版权全部.欢迎转载,请勿用于商业用途. 联系信箱:feixiaoxing @163.com] 非常多project师都有一个不好的习惯,由于大多数itproject师都喜欢写代码.可是不喜欢 ...

  9. (四)Thymeleaf标准表达式之——[3->6] 操作符(文本、算术、布尔、比较及相等)

    2.3 文本操作符 模板名称:text.html 连接符: +   可以是任意字符和表达式等 文本替换符:|    不能表达出条件表达式(官网:只能是变量表达式) e.g. 1.<span th ...

  10. apt-update 更新失败 (无法连接到ubuntu服务器)

    解决方法: 找一个可以更新的系统,拷贝里面的sources.list文件,并将原系统的sources.list进行备份.