France '98 - UVa 542 概率dp

本文深入探讨了信息技术领域的最新趋势和发展,涵盖了从基础到高级的技术主题,包括但不限于前端开发、后端开发、移动开发、游戏开发、大数据开发、开发工具、嵌入式开发等细分领域。文章详细介绍了各领域的关键技术和实践,旨在为读者提供全面的技术洞察。

France '98 

Today the first round of the Soccer World Championship in France is coming to an end. 16 countries are remaining now, among which the winner is determined by the following tournament:

 1 Brazil -----+
               +-- ? --+
 2 Chile ------+       |
                       +-- ? --+
 3 Nigeria ----+       |       |
               +-- ? --+       |
 4 Denmark ----+               |
                               +-- ? --+
 5 Holland ----+               |       |
               +-- ? --+       |       |
 6 Yugoslavia -+       |       |       |
                       +-- ? --+       |
 7 Argentina --+       |               |
               +-- ? --+               |
 8 England ----+                       |
                                       +-- World Champion
 9 Italy ------+                       |
               +-- ? --+               |
10 Norway -----+       |               |
                       +-- ? --+       |
11 France -----+       |       |       |
               +-- ? --+       |       |
12 Paraguay ---+               |       |
                               +-- ? --+
13 Germany ----+               |
               +-- ? --+       |
14 Mexico -----+       |       |
                       +-- ? --+
15 Romania ----+       |
               +-- ? --+
16 Croatia ----+

For each possible match A vs. B between these 16 nations, you are given the probability that team A wins against B. This (together with the tournament mode displayed above) is sufficient to compute the probability that a given nation wins the World Cup. For example, if Germany wins against Mexico with 80%, Romania against Croatia with 60%, Germany against Romania with 70% and Germany against Croatia with 90%, then the probability that Germany reaches the semi-finals is 80% * (70% * 60% + 90% * 40%) = 62.4%.


Your task is to write a program that computes the chances of the 16 nations to become the World Champion '98.

Input 

The input file will contain just one test case.

The first 16 lines of the input file give the names of the 16 countries, from top to bottom according to the picture given above.

Next, there will follow a 16 $\times$ 16 integer matrix P where element pij gives the probability in percent that country #i defeats country #j in a direct match. Country #i means the i-th country from top to bottom given in the list of countries. In the picture above Brazil is #1 and Germany is #13, so p1,13 = 55 would mean that in a match between Brazil and Germany, Brazil wins with a probability of 55%.

Note that matches may not end with a draw, i.e. pij + pji = 100 for all i,j.

Output 

Output 16 lines of the form `` XXXXXXXXXX p=Y.YY%", where XXXXXXXXXX is the country's name, left-justified in a field of 10 characters, and Y.YY is their chance in percent to win the cup, written to two decimal places. Use the same order of countries like in the input file.

Sample Input 

Brazil
Chile
Nigeria
Denmark
Holland
Yugoslavia
Argentina
England
Italy
Norway
France
Paraguay
Germany
Mexico
Romania
Croatia
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
35 50 35 45 40 35 35 50 30 40 25 40 25 40 35 35
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
40 55 40 50 45 40 40 55 35 45 30 45 30 45 40 40
45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
35 50 35 45 40 35 35 50 30 40 25 40 25 40 35 35
55 70 55 65 60 55 55 70 50 60 45 60 45 60 55 55
45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
60 75 60 70 65 60 60 75 55 65 50 65 50 65 60 60
45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
60 75 60 70 65 60 60 75 55 65 50 65 50 65 60 60
45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50

Sample Output 

Brazil     p=8.54%
Chile      p=1.60%
Nigeria    p=8.06%
Denmark    p=2.79%
Holland    p=4.51%
Yugoslavia p=7.50%
Argentina  p=8.38%
England    p=1.56%
Italy      p=9.05%
Norway     p=3.23%
France     p=13.72%
Paraguay   p=3.09%
Germany    p=13.79%
Mexico     p=3.11%
Romania    p=5.53%
Croatia    p=5.53%

题意:给你如图所示的比赛方式,以及每两个人比赛的获胜概率,问每个人最后成为冠军的概率。

思路:dp[i][j][k]表示在第i轮,从上数j位置的胜者是k的概率,然后进行转移即可。

AC代码如下:

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
double dp[20][20][20],p[20][20];
char s[20][40];
int main()
{
    int i,j,k,ret,f;
    double temp;
    for(i=1;i<=16;i++)
       scanf("%s",s[i]);
    for(i=1;i<=16;i++)
       for(j=1;j<=16;j++)
       {
           scanf("%lf",&p[i][j]);
           p[i][j]/=100;
       }
    for(i=0;i<16;i++)
       dp[1][i][i+1]=1;
    ret=16;
    for(i=1;i<=4;i++)
    {
        for(j=0;j<ret;j++)
        {
            for(k=1;k<=16;k++)
            if(dp[i][j][k]>0)
            {
                //printf("%d %d %d  %.2f\n",i,j,k,dp[i][j][k]);
                for(f=1;f<=16;f++)
                   if(f!=k)
                     dp[i+1][j/2][k]+=dp[i][j^1][f]*p[k][f];
                dp[i+1][j/2][k]*=dp[i][j][k];
            }
        }
        ret/=2;
    }
    for(i=1;i<=16;i++)
    {
        printf("%-10s p=%.2f",s[i],dp[5][0][i]*100);
        cout<<"%"<<endl;
    }
}



【直流微电网】径向直流微电网的状态空间建模与线性化:一种耦合DC-DC变换器状态空间平均模型的方法 (Matlab代码实现)内容概要:本文介绍了径向直流微电网的状态空间建模与线性化方法,重点提出了一种基于耦合DC-DC变换器状态空间平均模型的建模策略。该方法通过对系统中多个相互耦合的DC-DC变换器进行统一建模,构建出整个微电网的集中状态空间模型,并在此基础上实施线性化处理,便于后续的小信号分析与稳定性研究。文中详细阐述了建模过程中的关键步骤,包括电路拓扑分析、状态变量选取、平均化处理以及雅可比矩阵的推导,最终通过Matlab代码实现模型仿真验证,展示了该方法在动态响应分析和控制器设计中的有效性。; 适合人群:具备电力电子、自动控制理论基础,熟悉Matlab/Simulink仿真工具,从事微电网、新能源系统建模与控制研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握直流微电网中多变换器系统的统一建模方法;②理解状态空间平均法在非线性电力电子系统中的应用;③实现系统线性化并用于稳定性分析与控制器设计;④通过Matlab代码复现和扩展模型,服务于科研仿真与教学实践。; 阅读建议:建议读者结合Matlab代码逐步理解建模流程,重点关注状态变量的选择与平均化处理的数学推导,同时可尝试修改系统参数或拓扑结构以加深对模型通用性和适应性的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值