Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 175   Accepted Runs: 139

     这一题非常的简单,因为题目已经说明只有16个国家,则对它进行穷举即可,可以分四步走,第一步:求出每个国家晋级8强赛的概率 第二步:求出每个国家晋级半决赛的概率 第三步:求出每个国家晋级决赛的概率 第四步:求出每个获得冠军的概率

代码:

 

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