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. Makefile学习之一

    Makefile注意: 1.Makefile由三部分组成:目标,依赖,命令: 2.命令行前必须有一个tab键作为开头: 3.定义变量:objects=main.o abc.o 使用$(objects) ...

  2. Vue计算属性和监听属性

    一.计算属性 计算属性关键词: computed.计算属性在处理一些复杂逻辑时是很有用的. 可以看下以下反转字符串的例子: <div id="app"> {{ mess ...

  3. Myeclipse 编译等级

    1.Java compiler level does not match the version of the installed Java project facet. 问题描述:编译等级不匹配 解 ...

  4. 2017.7.21 linux下进程管理工具supervisord的安装与使用

    参考来自:http://blog.haohtml.com/archives/15145 0 操作环境 1 supervisord的介绍 Supervisord是用Python实现的一款非常实用的进程管 ...

  5. hdu 1030 Delta-wave(数学题+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...

  6. 编译和安装在Windows上橡胶树 (Compiling and Installing Yate on Windows)

    编译和安装在Windows上橡胶树     有两种方法来安装橡胶树下窗口: 下载并安装橡胶树 下载后页面设置. 另一个选择是下载橡胶树从SVN并编译它. 内容 ( 隐藏] 1 安装使用设置橡胶树 2  ...

  7. 倍福TwinCAT(贝福Beckhoff)基础教程5.1 TwinCAT-1 获取和设置系统时间

    使用功能块NT_GetTime,NETID填写两个单引号表示本机,START就是一个触发信号,一般的功能块都需要一个上升沿触发执行,最后的输出类型都是让系统自己决定,然后统一把这些变量放到全局变量中( ...

  8. iptables firewall-cmd

    iptables -F iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT iptables -A IN ...

  9. 【C#】.NET提供了哪些类型来实现反射

    实现反射的类型大多数都定义在System.Reflection命名空间之下. Assembly 定义一个Assembly,它是可重用.无版本冲突并且可自我描述的公共语言运行库应用程序构造块. Asse ...

  10. 自己定义circle

    写了一个还不错的自己定义控件.用来展示完毕度或能力值,程序中配置好所占百分比.图中就能够用外面的圆环来显示百分比,效果还是不错的~ watermark/2/text/aHR0cDovL2Jsb2cuY ...