PKU 3716 Panda's Birthday Present (概率问题)
来源:互联网 发布:虚拟机ubuntu怎么联网 编辑:程序博客网 时间:2024/05/17 09:38
题意:有4个骰子,每个骰子每面包含red或blue两种颜色,每次投掷4个骰子,red向上的数量为分数,
现在给出第一次和第二次的分数,求第三次得分的期望。
思路参考http://hi.baidu.com/bfcdygoporbjuxr/item/569897ddc1fc561d21e2503f
#include<stdio.h>#include<string.h>#include<string>#include<map>#include<stack>#include<math.h>#include<queue>#include<vector>#include<stdlib.h>#include<iostream>#include<algorithm>using namespace std;#define N 2010#define eps 1e-5double C[7]={1,6,15,20,15,6,1};double pn[7][7][7][7];//pn[i][j][k][l]表示4个骰子各有i,j,k,l个red面的概率double pr[5][7][7][7][7];//pr[red][i][j][k][l]表示4个骰子每个骰子各有i,j,k,l个red面,且共有red个朝上的概率int cr[5];//每个骰子有多少个red面int t,n,m;int i,j,k,l;void init(){for(i=0;i<7;i++) for(j=0;j<7;j++)for(k=0;k<7;k++) for(l=0;l<7;l++)pn[i][j][k][l]=(C[i]*C[j]*C[k]*C[l])/(64*64*64*64);}void dfs1(int num,int red,double p){if(num==4){pr[red][cr[0]][cr[1]][cr[2]][cr[3]]+=p;return;}dfs1(num+1,red+1,p*cr[num]/6.0);dfs1(num+1,red,p*(6-cr[num])/6.0);}void dfs(int num){if(num==4){dfs1(0,0,1);return ;}for(int i=0;i<7;i++){cr[num]=i;dfs(num+1);}}int main(){init();dfs(0);scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);double P=0.0,ans=0.0;for(i=0;i<7;i++) for(j=0;j<7;j++)for(k=0;k<7;k++) for(l=0;l<7;l++)P+=pn[i][j][k][l]*pr[n][i][j][k][l]*pr[m][i][j][k][l];for(i=0;i<7;i++) for(j=0;j<7;j++) for(k=0;k<7;k++) for(l=0;l<7;l++)for(int r=0;r<5;r++)ans+=r*pn[i][j][k][l]*pr[r][i][j][k][l]*pr[n][i][j][k][l]*pr[m][i][j][k][l];ans/=P;printf("%.3lf\n",ans);}return 0;}
0 0
- PKU 3716 Panda's Birthday Present (概率问题)
- POJ 3716 Panda's Birthday Present 条件概率
- POJ 3716 Panda's Birthday Present 可能会
- HDU 2995 Another Panda's Birthday Present(条件概率|概率生成函数 )
- POJ3716-Panda's Birthday Present题解
- poj 3761 Panda's Birthday Present (数学公式推导~~推?)
- POJ-3682King Arthur's Birthday Celebration(概率DP)
- poj3682 King Arthur's Birthday Celebration (概率)
- POJ 3682 King Arthur's Birthday Celebration (概率DP)
- birthday present
- Birthday present
- Pku 3207 Ikki's Story IV - Panda's Trick
- CodeForces 248E Piglet's Birthday (概率)
- The birthday present
- 2017 ICPCECIC Birthday present
- POJ 3682 King Arthur's Birthday Celebration 概率DP
- poj3682[King Arthur's Birthday Celebration] 简单期望概率
- LightOJ1104 birthday parado(经典概率)
- Spring工作原理及其作用 .
- 读取Jpg和mask图片
- 挺好的图像学习博客
- iOS 的单例模式 dispatch_once
- 各种浏览器的userAgent及如何使用JS来检测游览器类型,或android是什么版本号
- PKU 3716 Panda's Birthday Present (概率问题)
- Android之WindowManager
- [ACM] POJ 1068 Parencodings(模拟)
- OpenCV学习教程入门篇<一、介绍>
- android文件输出问题
- QtCreator 用纯代码编写应用程序与命令行编译
- thinkphp中的实例化模型的四种方法
- Xenomai 检测某一线程从Xenomai域切换到Linux域
- 使用xcode5做单元测试