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 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.
输出
示例输入
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%. 按足球比赛的规则(你懂得),问每个队最后得冠军的几率; 思路:如上图所示,一共有四轮比赛,开辟四个数组,通过递推求得存每一轮中每个队战胜的概率,在第四轮比赛中就产生了冠军。
#include<stdio.h>
#include<string.h> int main()
{
double dp1[],dp2[],dp3[],dp4[];
char cou[][];
double maxtri[][]; for(int i = ; i <= ; i++)
scanf("%s",cou[i]);
for(int i = ; i <= ; i++)
{
for(int j = ; j <= ; j++)
{
int x;
scanf("%d",&x);
maxtri[i][j] = x*0.01;
}
} for(int i = ; i <= ; i++)
{
if(i% == )
dp1[i] = maxtri[i][i-];
else dp1[i] = maxtri[i][i+];
}
for(int i = ; i <= ; i++)
{
if(i% == )
dp2[i] = dp1[i] *(dp1[i+]*maxtri[i][i+] + dp1[i+]*maxtri[i][i+]);
else if(i% == )
dp2[i] = dp1[i] *(dp1[i+]*maxtri[i][i+] + dp1[i+]*maxtri[i][i+]);
else if(i% == )
dp2[i] = dp1[i] *(dp1[i-]*maxtri[i][i-] + dp1[i-]*maxtri[i][i-]);
else
dp2[i] = dp1[i] *(dp1[i-]*maxtri[i][i-] + dp1[i-]*maxtri[i][i-]);
}
for(int i = ; i <= ; i++)
{
if(i% >= && i% <= )
{
if(i/ == )
dp3[i] = dp2[i] * (dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][]);
else if(i/ == )
dp3[i] = dp2[i] * (dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][]);
}
else if (i% == || (i% >= && i% <= ))
{
if(i >= && i <= )
dp3[i] = dp2[i] * (dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][]);
else
dp3[i] = dp2[i] * (dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][] + dp2[]*maxtri[i][]);
}
} for(int i = ; i<= ; i++)
{
if(i <= )
dp4[i] = dp3[i] *(dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+
dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+
dp3[]*maxtri[i][]+dp3[]*maxtri[i][]);
else dp4[i] = dp3[i] *(dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+
dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+dp3[]*maxtri[i][]+
dp3[]*maxtri[i][]+dp3[]*maxtri[i][]);
} for(int i = ; i <= ; i++)
{
int len = strlen(cou[i]);
printf("%s",cou[i]);
for(int j = len+; j <= ; j++)
printf(" ");
printf("p=%.2lf%%\n",dp4[i]*);
}
return ; }
France \'98(概率)的更多相关文章
- uva 542 - France '98(概率)
题目链接:uva 542 - France '98 题目大意:有16支球队比赛,给出16支球队的名称,然后给出16*16的表格,g[i][j] 表示i队胜j队的概率,问说16支球队获得总冠军的概率. ...
- France '98
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=30506#problem/H #include<map> #include&l ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- poj 3071 Football(概率dp)
id=3071">http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- python + pymysql连接数据库报“(2003, "Can't connect to MySQL server on 'XXX数据库地址' (timed out)")”
python + pymysql连接数据库报"(2003, "Can't connect to MySQL server on 'XXX数据库地址' (timed out)&quo ...
- 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Midterm
Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...
- 43. 动态规划求解n个骰子的点数和出现概率(或次数)[Print sum S probability of N dices]
[题目] 把N个骰子扔在地上,所有骰子朝上一面的点数之和为S.输入N,打印出S的所有可能的值出现的概率. [分析] 典型的动态规划题目. 设n个骰子的和为s出现的次数记为f(n,s),其中n=[1-N ...
随机推荐
- Android&Java的学习新的等
学习资料 很久没写博客了.适逢这次Srtp项目学弟学妹们要学习Java与Android,我就总结一些学习的教材.方法,分享写材料与心得.纯个人观点,如有不周之处欢迎指出,大家共同探讨提高. *** 教 ...
- json、xml ---- 数据格式生成类
自己写的一个生成json/xml 格式数据的类,可用于api数据传输: <?php class Response{ /** *生成指定数据格式 *@param intval $code 状态码 ...
- 在Linux下用netstat查看网络状态、端口状态
在Linux下用netstat查看网络状态.端口状态 在linux一般使用netstat 来查看系统端口使用情况步. netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表.实 ...
- codevs 3052 多米诺 二分图匹配
/*codevs 3052 二分图匹配 把矩阵分两批 黑和白 且黑白不相交 这就构成了二分图的两部分 然后求最大匹配*/ #include<cstdio> #include<cstr ...
- 比较好的自学IT的网站
其实这是我在知乎的一个回答,由于收藏人数众多,我想也许对有些初学者有用,故同步到Blog.此文章和知乎答案将不定期同步更新(知乎答案传送门). 入门与进阶: 学堂在线-最大的中文慕课(MOOC)平台学 ...
- java_Collection 类集
大体概念
- C#语法糖之第一篇:自动属性&隐式类型
今天给大家分享一下C#语法糖的简单的两个知识点吧. 自动属性:在 C# 4.0 和更高版本中,当属性的访问器中不需要其他逻辑时,自动实现的属性可使属性声明更加简洁. 客户端代码还可通过这些属性创建对象 ...
- ios9 http请求失败的问题
最近做项目的时候 将电脑版本升级到10.11.3 xcode'升级到 7.2 但是在模拟器上边进行数据请求的时候告诉我说网路哦有问题 截图如下 通过网络终于找到了解决的办法 原来是ios9 采用 ...
- Python:if-while-for
#!/usr/bin/python3 #if elif else print("开始猜数字游戏") num = int(input("请输入数字")) stan ...
- Android 学习手札(备注)
1.在Android 应用程序中不能使用System.out.println(..)来输出信息,而要使用Log类中的静态方法输出调试信息. Log.d("onStart", &qu ...