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.

输入

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 x 16 integer matrix P where element pijgives 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 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.

示例输入

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 

示例输出

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%

题意:有16个队,进行如图所示的流程进行比赛,下面给出的是16*16的矩阵,pij表示i对战胜j对的概率是 pij%. 按足球比赛的规则(你懂得),问每个队最后得冠军的几率;

思路:如上图所示,一共有四轮比赛,开辟四个数组,通过递推求得存每一轮中每个队战胜的概率,在第四轮比赛中就产生了冠军。

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 int main()
 5 {
 6     double dp1[20],dp2[20],dp3[20],dp4[20];
 7     char cou[20][30];
 8     double maxtri[20][20];
 9 
10     for(int i = 1; i <= 16; i++)
11         scanf("%s",cou[i]);
12     for(int i = 1; i <= 16; i++)
13     {
14         for(int j = 1; j <= 16; j++)
15         {
16             int x;
17             scanf("%d",&x);
18             maxtri[i][j] = x*0.01;
19         }
20     }
21 
22     for(int i = 1; i <= 16; i++)
23     {
24         if(i%2 == 0)
25             dp1[i] = maxtri[i][i-1];
26         else dp1[i] = maxtri[i][i+1];
27     }
28     for(int i = 1; i <= 16; i++)
29     {
30         if(i%4 == 1)
31             dp2[i] = dp1[i] *(dp1[i+2]*maxtri[i][i+2] + dp1[i+3]*maxtri[i][i+3]);
32         else if(i%4 == 2)
33             dp2[i] = dp1[i] *(dp1[i+1]*maxtri[i][i+1] + dp1[i+2]*maxtri[i][i+2]);
34         else if(i%4 == 3)
35             dp2[i] = dp1[i] *(dp1[i-1]*maxtri[i][i-1] + dp1[i-2]*maxtri[i][i-2]);
36         else
37             dp2[i] = dp1[i] *(dp1[i-2]*maxtri[i][i-2] + dp1[i-3]*maxtri[i][i-3]);
38     }
39     for(int i = 1; i <= 16; i++)
40     {
41         if(i%8 >= 1 && i%8 <= 4)
42         {
43             if(i/8 == 0)
44                 dp3[i] = dp2[i] * (dp2[5]*maxtri[i][5] + dp2[6]*maxtri[i][6] + dp2[7]*maxtri[i][7] + dp2[8]*maxtri[i][8]);
45             else if(i/8 == 1)
46                 dp3[i] = dp2[i] * (dp2[13]*maxtri[i][13] + dp2[14]*maxtri[i][14] + dp2[15]*maxtri[i][15] + dp2[16]*maxtri[i][16]);
47         }
48         else if (i%8 == 0 || (i%8 >= 5 && i%8 <= 7))
49         {
50             if(i >= 5 && i <= 8)
51                 dp3[i] = dp2[i] * (dp2[1]*maxtri[i][1] + dp2[2]*maxtri[i][2] + dp2[3]*maxtri[i][3] + dp2[4]*maxtri[i][4]);
52             else
53                 dp3[i] = dp2[i] * (dp2[9]*maxtri[i][9] + dp2[10]*maxtri[i][10] + dp2[11]*maxtri[i][11] + dp2[12]*maxtri[i][12]);
54         }
55     }
56 
57     for(int i = 1; i<= 16; i++)
58     {
59         if(i <= 8)
60             dp4[i] = dp3[i] *(dp3[9]*maxtri[i][9]+dp3[10]*maxtri[i][10]+dp3[11]*maxtri[i][11]+
61                               dp3[12]*maxtri[i][12]+dp3[13]*maxtri[i][13]+dp3[14]*maxtri[i][14]+
62                               dp3[15]*maxtri[i][15]+dp3[16]*maxtri[i][16]);
63         else dp4[i] = dp3[i] *(dp3[1]*maxtri[i][1]+dp3[2]*maxtri[i][2]+dp3[3]*maxtri[i][3]+
64                                dp3[4]*maxtri[i][4]+dp3[5]*maxtri[i][5]+dp3[6]*maxtri[i][6]+
65                                dp3[7]*maxtri[i][7]+dp3[8]*maxtri[i][8]);
66     }
67 
68     for(int i = 1; i <= 16; i++)
69     {
70         int len = strlen(cou[i]);
71         printf("%s",cou[i]);
72         for(int j = len+1; j <= 11; j++)
73             printf(" ");
74         printf("p=%.2lf%%\n",dp4[i]*100);
75     }
76     return 0;
77 
78 
79 }
View Code

 

转载于:https://www.cnblogs.com/LK1994/p/3405479.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Yes, Adeo is a French retail company that specializes in home improvement and DIY (Do-It-Yourself) products. It was founded in 1923 and is headquartered in Roubaix, France. The company operates several retail chains, including Leroy Merlin, Weldom, Zodio, and Bricoman, which have stores in various countries around the world. Adeo is one of the largest home improvement retailers in Europe and has a strong presence in the French market. ### 回答2: 是的,我知道法国的adeo公司。adeo是一家在法国本土有很高知名度的零售集团企业,也是欧洲重要的零售巨头之一。该公司在1999年成立,总部设在法国北部的里尔市。adeo公司以家居装饰和建材销售为主要业务,旗下拥有许多知名品牌,如Leroy Merlin、Weldom、Zodio等。经过多年的发展,adeo已经在法国本土拥有超过1000家门店,同时还在其他欧洲国家设立了分支机构。adeo公司致力于提供高质量、创新和可持续的产品,追求满足客户的需求和提升客户生活质量。它以其多样化的产品、优质的服务和竞争力的价格受到了消费者的青睐。adeo还非常注重企业社会责任,积极参与公益事业和环保活动。在法国,adeo公司在家居和建材市场上具有很强的竞争力,并且在欧洲市场上也有很大的影响力。 ### 回答3: 是的,我知道在法国的Adeo公司。Adeo是世界领先的家居装饰和建筑材料零售集团之一。该公司总部位于法国北部的里尔,成立于1923年。Adeo通过不同的零售品牌,在全球超过15个国家经营着数千家店铺。其中最著名的品牌包括“Leroy Merlin”和“Brico Dépôt”。 Adeo公司致力于为消费者提供各种家居装饰和建筑材料产品。他们销售包括室内家具、灯具、厨房和卫浴配件、地板和墙壁材料等等。通过不断创新和引入新产品,Adeo公司在市场上享有很高的声誉。 除了在零售领域,Adeo公司还在可持续发展方面积极投入。他们采取了一系列的措施,包括减少能源消耗和环境影响,以及提供可再生能源解决方案。这使得Adeo公司成为可持续发展的领导者之一。 总的来说,Adeo公司是一家在法国拥有很高知名度的家居装饰和建筑材料零售集团。他们通过多个品牌在全球范围内经营着数千家店铺,并致力于为消费者提供各种高质量的产品。与此同时,他们还积极投入可持续发展领域,成为环保和创新的推动者。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值