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–
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% OJ-ID:
HDU-1493 author:
Caution_X date of submission:
20190930 tags:
概率DP description modelling:
投掷10次骰子,掷出的点数概率已给出,问掷完后落在5, 12, 22, 29, 33, 38, 42, 46, 50 55点上的概率。 major steps to solve it:
1.dp[i][j]:=第j次投在第i格上的概率,p[]:=各个点的概率
2.dp[i][1]=p[i];
3.dp[i+k][j+1]+=dp[i][j]*p[k]; AC CODE:
#include<bits/stdc++.h>
using namespace std;
double p[];
double dp[][];
int a[]={,,,,,,,,,};
int main()
{
//freopen("input.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--) { for(int i=; i<=; i++) {
scanf("%lf",&p[i]);
} memset(dp,,sizeof(dp));
for(int i=;i<=;i++){
dp[i][]=p[i];
} for(int j=; j<=; j++) {
for(int i=; i<=; i++) {
for(int k=; k<=; k++) {
dp[i+k][j+]+=dp[i][j]*p[k];
}
}
} for(int i=; i<; i++) {
double ans=;
for(int j=;j<=;j++){
ans+=dp[a[i]][j];
}
printf("%d: %.1f%%\n",a[i],ans*);
}
if(t) printf("\n"); }
return ;
}

最新文章

  1. Hibernate中事务声明
  2. 使用jquery实现搜索框的位置变换
  3. Scrum2.0 项目基本完成
  4. SOA_Oracle SOA Suite and BPM Suite 11g官方虚拟机安装指南(案例)
  5. Shell教程2-变量
  6. tomcat 解析(二)-消息处理过程
  7. 转载CSDN (MVC WebAPI 三层分布式框架开发)
  8. Chrome浏览器报错:Origin null is not allowed by Access-Control-Allow-Origin.
  9. idea不能加载xml
  10. JavaSE教程-03Java中分支语句与四种进制转换
  11. KandQ:单例模式的七种写法及其相关问题解析
  12. 一个maven项目打多个可执行Jar文件
  13. RAC(ReactiveCocoa)概括
  14. vue项目 使用Hbuilder打包app 设置沉浸式状态栏
  15. PhpStorm 2017破解
  16. 如何最快速的找到页面某一元素所绑定的点击事件,并查看js代码
  17. js中script的上下放置区别 , Dom的增删改创建
  18. 前后端同学必会的Linux基础命令
  19. linux下mysql安装报错及修改密码登录等等
  20. Python面向对象编程 - 一个记事本程序范例(一)

热门文章

  1. nodejs环境下的socket通信
  2. MyCat启动失败 Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: rebirth.a: rebirth.a: unknown error
  3. Koa + GraphQL 示例
  4. Python数据分析揭秘知乎大V的小秘密
  5. [PHP] 近期接手現有的企邮前端框架业务所遇困难
  6. CentOS添加用户,管理员权限
  7. jdk的一条命令查看运行参数
  8. ES3、ES5、ES6对象代理的写法差异
  9. /usr/lib64/python2.7/subprocess.py&quot;, line 1327, in _execute_child
  10. 6.gitlab 备份