zoukankan      html  css  js  c++  java
  • POJ3071 Football 概率DP 简单

    http://poj.org/problem?id=3071

    题意:有2^n个队伍,给出每两个队伍之间的胜率,进行每轮淘汰数为队伍数/2的淘汰赛(每次比赛都是相邻两个队伍进行),问哪只队伍成为冠军概率最大。
    很基础。
    代码
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 #include<algorithm>
     5 #include<cmath>
     6 #include<queue>
     7 using namespace std;
     8 const int maxn=1;
     9 const double eps=1e-8;
    10 const int modn=998244353;
    11 int n;
    12 double a[1<<8][1<<8]={};
    13 double f[1<<8][10]={};
    14 int main(){
    15     while(scanf("%d",&n)){
    16         if(n==-1)return 0;
    17         memset(f,0,sizeof(f));memset(a,0,sizeof(a));
    18         int z=1<<n;
    19         for(int i=1;i<=z;i++){
    20             for(int j=1;j<=z;j++){
    21                 scanf("%lf",&a[i][j]);
    22             }
    23         }
    24         for(int i=1;i<=z;i++){f[i][0]=1;}
    25         for(int i=1;i<=n;i++){
    26             for(int j=1;j<=z;j++){
    27                 int t=(j-1)/(1<<i);
    28                 t=t*(1<<i); t+=(1<<(i-1))+1;
    29                 if(t<=j)t=t-(1<<(i-1));
    30                 int en=t+(1<<(i-1))-1;
    31                 for(int w=t;w<=en;w++){
    32                     f[j][i]+=a[j][w]*f[w][i-1]*f[j][i-1];
    33                 }
    34             }
    35         }double ans=0.0;int id=0;
    36         for(int i=1;i<=z;i++){
    37             if(f[i][n]>ans){
    38                 ans=f[i][n];
    39                 id=i;
    40             }
    41         }printf("%d
    ",id);
    42     }
    43     return 0;
    44 }
    View Code
  • 相关阅读:
    otto-group-product-classification-challenge(Pytorch处理多分类问题)
    F1值
    win10 安装torch
    win10 安装 scrapy
    头条 街拍
    1029 Median
    欧拉回路
    Pre-Post
    Django 安装for Python3.4
    Python 安装for Windows
  • 原文地址:https://www.cnblogs.com/137shoebills/p/7786514.html
Copyright © 2011-2022 走看看