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. 关于#include文件包含

    1.对于函数头文件: #include <filename> 一般对于标准库文件以一个.h后缀结尾: 2.对于本地文件: #include "filename.h" 对 ...

  2. vs2015安装VAssistX以后,去除中文注释会有红色下划线方法

    ---恢复内容开始--- 环境:Visual Studio 2015 问题:代码中出现中文后会带下划线,不舒服-----解决办法. 1.安装完Visual Assist X后会在VS2015的菜单栏出 ...

  3. div 事件透传

    有些时候,我们会想要把一个 div 层覆盖在另一个 div 层上,要让下层的 div 响应鼠标事件而上层的不响应仅仅只做内容展示. 这种时候,我们就可以用到一个 CSS 属性:pointer-even ...

  4. Windows 10 Enterprise LTSB版本

    Windows 10 Enterprise 评估版  |  90 天  Win10 企业版 LTSB版 14393.0.160715-1616.RS1_RELEASE_CLIENTENTERPRISE ...

  5. 倍福TwinCAT(贝福Beckhoff)基础教程2.2 TwinCAT常见类型使用和转换_指针

    定义pt为指向INT类型的指针,在程序中取得var_int1的地址(INT类型),然后将地址对应的数据还原给var_int2(pt^的写法)     更多教学视频和资料下载,欢迎关注以下信息: 我的优 ...

  6. C++Singleton的DCLP(双重锁)实现以及性能测评

      本文系原创,转载请注明:http://www.cnblogs.com/inevermore/p/4014577.html   根据维基百科,对单例模式的描述是: 确保一个类只有一个实例,并提供对该 ...

  7. MYSQL优化之碎片整理

    MYSQL优化之碎片整理   在MySQL中,我们经常会使用VARCHAR.TEXT.BLOB等可变长度的文本数据类型.不过,当我们使用这些数据类型之后,我们就不得不做一些额外的工作--MySQL数据 ...

  8. 自定义HttpReqeust,解决request请求参数只能拿一次就失效的问题

    定义一个过滤器并实现如下方法 @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResp ...

  9. 互联网我来了 -- 2. js中&quot;异步/堵塞&quot;等概念的简析

    一.什么是"异步非堵塞式"? 这个名字听起来非常恶心难懂,但假设以 买内裤 这件事情来比喻运行程序的话就非常easy理解"异步非堵塞式"的涵义了. 比如你是一个 ...

  10. 无法调试存储过程,无法启动T-SQL调试

    用本机管理员或者具有SYSADMIN角色的帐号登录,不要用.,用实例名来连接