poj 3071
来源:互联网 发布:麦卡锡主义知乎 编辑:程序博客网 时间:2024/05/22 16:46
#include<iostream>#include<stdio.h>using namespace std;double dp[8][130];double p[130][130];int num[10]={1,2,4,8,16,32,64,128};int opponent;int main(){ int n; while(cin>>n&&n!=-1){ for(int i=0;i<num[n];i++){ for(int j=0;j<num[n];j++){ //cin>>p[i][j]; scanf("%lf",&p[i][j]); //if(i==j)p[i][j]=1.0; } } for(int i=0;i<num[n];i++)dp[0][i]=1.0; for(int i=1;i<=n;i++){//compute dp, i is round int players_in_same_round=num[i-1]; for(int team=0;team<num[n];team++){//每一轮后每一队仍未被淘汰的概率 dp[i][team]=0.0; opponent=team>>(i-1); opponent^=1; opponent=opponent<<(i-1); //cout<<"round "<<i<<", team "<<team<<" opponent is "<<opponent<<" and fight with team "<<endl; for(int k=0;k<players_in_same_round;k++){ //cout<<k+opponent<<','; dp[i][team]+=p[team][k+opponent]*dp[i-1][k+opponent]*dp[i-1][team]; } //cout<<endl; } } double maxteam=0,maxp=0; //for(int i=0;i<num[n];i++)cout<<dp[n][i]<<' '; //cout<<endl; for(int team=0;team<num[n];team++){ if(maxp<dp[n][team]){maxteam=team;maxp=dp[n][team];} } cout<<maxteam+1<<endl; } return 0;}
0 0
- POJ 3071
- poj 3071
- poj 3071
- POJ 3071
- poj-3071
- poj 3071
- poj 3071 Football
- poj 3071 football
- 【概率dp】POJ 3071
- poj 3071 概论 dp
- POJ 3071 Football
- POJ-3071-Football
- poj 3071 概率dp
- poj 3071 Football
- poj 3071 Football
- POJ 3071 Football
- POJ 3071 Football
- POJ 3071 Football
- Hadoop学习笔记(二)——map reduce Helloworld
- 电阻的基础知识
- collectionView
- Hive 数据倾斜总结
- 10款实用Android UI工具
- poj 3071
- 我还能坚持多久?
- VS2010 单文档+多视图+Outlook风格
- 获取程序的当前路径
- 简单socket编程,传输文件,JAVA
- 过去的我们,现在的我!
- 谷歌浏览器如何添加背景音乐
- 定位
- 远程控制计算机的原理