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 ...
随机推荐
- 使用AVCaptureSession显示相机预览
#import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface ViewController ...
- SQL Server中的20个系统变量
1.@@CONNECTIONS返回自上次启动 Microsoft SQL Server以来连接或试图连接的次数.示例:下面的示例显示了到当前日期和时间为止试图登录的次数.SELECT GETDATE( ...
- 10.31 afternoon
巧克力棒(chocolate)Time Limit:1000ms Memory Limit:64MB题目描述LYK 找到了一根巧克力棒,但是这根巧克力棒太长了, LYK 无法一口吞进去.具体地,这根巧 ...
- 国内流行的两大开源.net微信公众平台SDK对比分析
最近忙于微信周边的开发 难免手痒去搜索一下有没有相关的sdk直接拿来使 还真发现了不少 这里总结两个看起来比较不错的.net平台下基于C#语言开发的SDK 一个强大一个小巧 (1) Senparc.W ...
- 查询两个日期(时间)以内的数据,between and 或 and 连>= <=,to_date()
between and 方法 select * from kk.kkhmd where larq between(to_date('2008-9-3','yyyy-mm-dd')) and (to_d ...
- iOS 使用 FFmpeg
iOS 使用 FFmpeg 字数486 阅读288 评论7 喜欢5 集成 下载FFmpeg For iOS编译脚本: 打开 terminal 执行sh build-ffmpeg.sh: 步骤2执行完成 ...
- nginx 跨域。。。掉坑里了,小心
今天公司产品一个功能突然挂掉了...向客户演示之前出现了,手机端显示不能获取下载资源,可是急坏了一票人.. 通过手机端,调查服务器地址调用了http:/2342342.domain.hostname. ...
- [转] 使用CSS3 will-change提高页面滚动、动画等渲染性能 ---张鑫旭
一.先来看一个例子 下面这个例子来自某外文,我这里简单转述下. 视差滚动现在不是挺流行的嘛,然后Chris Ruppel当其使用background-attachment: fixed实现背景图片不随 ...
- Html5的<button>标签
1.标签是双标签,其内可添加文字,图片等复杂的样式. 2.不仅可以在表单中使用,还可以在其他块元素和内联元素中使用. 3.一般在input标签内添加name属性,否则提交后不显示.
- 最优秀的5个Linux文本编辑器
from: http://article.yeeyan.org/view/169956/174836 作为不久前举办的比赛的一部分内容,我从那些选出他们最喜欢的Linux文本编辑器的极客读者们那获得了 ...