QQpet exploratory park(DP)
QQpet exploratory park
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)的更多相关文章
- 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 ...
- 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.摇到 ...
- 【HDOJ】1493 QQpet exploratory park
超水的动态规划.最后要对概率求Sigma. #include <cstdio> #include <cstring> #include <cstdlib> #def ...
- HDU 4607 Park Visit (DP最长链)
[题目]题意:N个城市形成一棵树,相邻城市之间的距离是1,问访问K个城市的最短路程是多少,共有M次询问(1 <= N, M <= 100000, 1 <= K <= N). [ ...
- HDU-4607 Park Visit bfs | DP | dfs
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607 首先考虑找一条最长链长度k,如果m<=k+1,那么答案就是m.如果m>k+1,那么最 ...
- [CSP-S模拟测试]:Park(树上DP)
题目描述 公园里有$n$个雕像,有$n-1$条道路分别连接其中两个雕像,任意两个雕像可以直接或间接相连.现在每个景点$i$聚集着$P_i$只鸽子,旅行家手里有$v$数量的面包屑. 一旦旅行家在雕像$i ...
- 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 ...
- 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 ...
- C. Coloring Trees DP
传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 secon ...
随机推荐
- 我的MAC可能在设置环境变量的时候设置错了,现在整个MAC的vi,ls等命令都执行不了了。
1,在命令行中输入export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin这样可以保证命令行命令暂时可以使用.命令执行完之后先不要关闭终端或者c ...
- Gentoo:startx出现Failed to load module问题
安装完xorg-server后,startx启动桌面环境,出现缺少模块错误. 查看log: cat /var/log/Xorg.0.log | grep EE [75.403] (EE) Failed ...
- pl/sql(2)
1.存储过程 (1)存储过程的创建及改动 语法: CREATE [OR REPLACE] PROCEDURE procedure_name [(parameter_name [IN | OUT | I ...
- 【HTML 元素】嵌入图像
img元素允许我们在HTML文档里嵌入图像. 要嵌入一张图像需要使用src和alt属性,代码如下: <img src="../img/example/img-map.jpg" ...
- POJ 2388:Who's in the Middle
Who's in the Middle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 31015 Accepted: 1 ...
- Linux组件封装(二)中条件变量Condition的封装
条件变量主要用于实现线程之间的协作关系. pthread_cond_t常用的操作有: int pthread_cond_init(pthread_cond_t *cond, pthread_conda ...
- CSS——display(Block none inline等)属性的用法
在一般的CSS布局制作时候,我们常常会用到display对应值有block.none.inline这三个值.下面我们来分别来认识和学习什么时候用什么值.这里通过CSS display知识加实例.图演示 ...
- Django与SQL语言中——NULL与空字符串的区别
SQL有指定空值的独特方式,它把空值叫做NULL. Null在数据库中表示 不知道的数据,主要有3种意思: 1)知道数据存在,但不知道具体值. 2)不知道数据是否存在. 3)数据不存在. 在SQL中, ...
- Windows操作系统设置代理
1.打开控制面板 2.点击网络和Internet 3.点击Internet选项 4.点击连接Tab页 5.点击局域网设置 6.选中代理服务器 7.输入代理的地址和端口号
- python 搭建环境
直接命令行里面 1.进入相应的目录 ,然后python,然后python setup.py 2.或者直接python C:\Python27\Lib\site-packages\xlrd-0.9.3\ ...