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 ...
随机推荐
- appium python api(转)
Appium_Python_Api文档 1.contextscontexts(self): Returns the contexts within the current session. 返回当前会 ...
- .net开发常用的第三方开发组件
转自:http://www.cnblogs.com/damsoft/p/6100323.html .net开发常用的第三方组件: 1.RSS.NET.dll: RSS.NET是一款操作RSS feed ...
- python中pickle简介
2017-04-10 pickle是用来加工数据的,可以用来存取结构化数据. 例如: 一个字典a = {'name':'Timmy','age':26},用pickle.dump存到本地文件,所存数据 ...
- FizzBuzz and Fibonacci优化
***************************************转载请注明出处:http://blog.csdn.net/lttree************************** ...
- Android Crash 定位
本文介绍了如何在 Android 手机发生 Crash 时进行 Log 分析的方法, 它可以帮助测试人员快速定位 Android 手机 Crash 发生的原因,同时给研发人员提供有效修改 Bug 的 ...
- nodeJs-autoMerge
/** * Created by Administrator on 2016/1/16. */ var fs = require('fs'); var filedir='automay'; conso ...
- 倍福TwinCAT(贝福Beckhoff)基础教程4.2 TwinCAT如何读写CSV文件
本程序只是在官方范例程序上稍作修改,在官方原有的范例中,演示了多种模式的读写(可以认为CSV文件是比TXT文件需要更多数据量的时候使用,比如记录一个小型的数据库集合) 但是写的比较混乱,甚至没有H ...
- Python图像处理(11):k均值
快乐虾 http://blog.csdn.net/lights_joy/ 欢迎转载,但请保留作者信息 K均值是一个经典的聚类算法,我们试试在python下使用它. 首先以(-1.5, -1.5)和(1 ...
- iOS开发之状态栏隐藏(问题篇)
一.基本应用 相信基本的隐藏办法网上很多,这里只简单说明一下 1⃣️改变全局状态栏 1.在项目的Info.plist文件里设置UIViewControllerBasedStatusBarAppeara ...
- Atitit.获取approot api 应用根路径 java c#.net php asp
Atitit.获取approot api 应用根路径 java c#.net php asp 1. 如果根路径返回empty,否则返回/app,兼容getContextPath() <scrip ...