题意:点球大战,轮流每队点射5个球,A先踢。如果当前比分已经能直接让比赛胜利接下来的球就不需要踢了。问最后的得分是题所给出的得分的概率

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double a[6],b[6],ans;
int scord1,scord2;
void dfs(int rt,double p,int c1,int c2)
{int id=(rt+1)/2;  // 当前是哪个人踢。if(rt&1) {if((c1>c2+6-id) || (c2>c1+6-id)) {    // 如果比赛结束就提前终止    轮到A球员踢if(c1==scord1 && c2==scord2) ans+=p;return;}}else {                                      // 轮到B球员踢if((c1>c2+6-id) || (c2>c1+5-id)) {if(c1==scord1 && c2==scord2) ans+=p;return;}}if(rt&1) {if(c1<scord1) dfs(rt+1,p*a[id],c1+1,c2);dfs(rt+1,p*(1-a[id]),c1,c2);}else {if(c2<scord2) dfs(rt+1,p*b[id],c1,c2+1);dfs(rt+1,p*(1-b[id]),c1,c2);}
}
int main()
{int i,j,cc=0;while(scanf("%lf",&a[1])!=EOF) {for(i=2;i<=5;i++) scanf("%lf",&a[i]);for(i=1;i<=5;i++) scanf("%lf",&b[i]);scanf("%d-%d",&scord1,&scord2);ans=0;dfs(1,1,0,0);printf("Case %d: %.2lf%%\n",++cc,ans*100);}return 0;
}

"A penalty shoot-out (officially kicks from the penalty mark) is a method of determining the winner of an association football (soccer) match that is drawn after the regulation playing time and any applicable extra time periods have been played. In a penalty shoot-out, each team takes turns attempting a specified number of shots from the penalty mark (usually 5) that are only defended by the opposing team's goalkeeper, with the team scoring the most goals being declared the winner."
-- wikipedia
The game finally comes to the shoot-out. What will the final result be? "1-3!" You took a wild guess. But what is the probability that your guess is correct?
In this problem, team A kicks first (which is determined by a coin toss, as usual), both teams will attempt at most 5 shots (after all the 10 shots, the game may end in draw again), but the game will end as soon as the winner is already determined. For example, after the first 8 kicks the score is 3-2 (left side is team A’s score, right side is team B), then if the 9-th kick is a goal, the game will end immediately with score 4-2, because even team B got its last kick, it still loses for sure. Another example: if all the first 9 kicks are goals, the last kick (from team B) will still be performed, because although team B cannot win, the result might be a "draw", which is better than "lose".

Input

There will be at most 100 test cases. Each case contains two lines. The first line contains 10 floating numbers. The first 5 numbers are the goal probability of the players in team A (player 1 will shoot first, etc), the next 5 numbers are the goal probabilities of the players in team B. Each probability will have exactly one digit after the decimal point. The second line contains your guess, in the format of scoreA-scoreB. 0<=scoreA,scoreB<=5.

Output

For each test case, print the case number and the probability (in percentage) that your wild guess is correct, to 2 decimal places. An absolute error of 0.01% will be ignored.

Sample Input
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
1-3
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
2-0
1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
2-0
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
5-5
0.4 0.7 0.7 0.6 0.5 0.8 0.9 0.7 0.2 0.8
4-2
Sample Output
Case 1: 6.98%
Case 2: 100.00%
Case 3: 0.00%
Case 4: 0.47%
Case 5: 9.73%

CSU 1513 Kick the ball! 点球大战(DFS)相关推荐

  1. CSU 1457 Boggle (字典树+DFS)

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1457 读了一遍题想到了字典树,但不知道怎么写,队友一个单词一个单词的枚举,然后暴搜过 ...

  2. HDU题目分类大全【大集合】

    基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.  1032.1037.1040.1048.1056.105 ...

  3. hdoj杭电问题分类

    杭电上的题虽然多,但是一直苦于找不到问题分类,网页都是英文的,所以平时做题也没怎么看,今天仔细一看,问题分类竟然就在主页....做了那么久的题居然没发现,表示已经狗带..不要笑,不知道有没有像我一样傻 ...

  4. 转载:Hdu 题目分类

    原址点击 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056. ...

  5. 自然语言处理(NLP)之英文单词词性还原

    词形还原(Lemmatization)是文本预处理中的重要部分,与词干提取(stemming)很相似. 简单说来,词形还原就是去掉单词的词缀,提取单词的主干部分,通常提取后的单词会是字典中的单词,不同 ...

  6. MIT自然语言处理第二讲:单词计数(第三、四部分)

    MIT自然语言处理第二讲:单词计数(第三部分) 自然语言处理:单词计数 Natural Language Processing: (Simple) Word Counting 作者:Regina Ba ...

  7. 吴恩达深度学习课程deeplearning.ai课程作业:Class 2 Week 1 2.Regularization

    吴恩达deeplearning.ai课程作业,自己写的答案. 补充说明: 1. 评论中总有人问为什么直接复制这些notebook运行不了?请不要直接复制粘贴,不可能运行通过的,这个只是notebook ...

  8. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  9. HDU题目分类啊!!!

    分类一(详细): 分类二: 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.10 ...

最新文章

  1. DotNetNuke与MemberShip的结合(五年版) 三步汇总
  2. raidrive安装失败_记一次RaiDrive映射OneDrive遇到的问题
  3. linux ubutu书籍,Ubuntu Linux入门到精通[图书]
  4. Jmeter之JSON Path Extractor的使用(JSON-handle下载安装和使用)
  5. pytorch 中 torch.optim.Adam 方法的使用和参数的解释
  6. hysbz 2243 染色(树链剖分)
  7. IDEA快捷键+使用小技巧
  8. android UncaughtExceptionHandler全局异常处理
  9. 多媒体技术简答题和论述题
  10. 免费随机图片api接口
  11. H5音乐播放器skPlayer,已支持拉取网易云音乐歌单。
  12. 计算机桌面性能4.4怎么办,台式CPU性能怎么看?桌面CPU天梯图2018年1月更新版 (全文)...
  13. 阿里云安装MySQL数据库全过程(适合小白)
  14. 前端 关于汇率的计算
  15. 手机应用使用情况监控统计APP
  16. 贵州最新特种工(施工升降机)模拟题集及答案
  17. 实时高速实现改进型中值滤波算法_爱学术_免费下载
  18. 【错误记录/Blender】python中使用bpy模块
  19. 大学选修课计算机心得,大学选修课心得体会范文五篇
  20. 商务谈判中有哪些谈判技巧?

热门文章

  1. 汉字转化成拼音的源代码
  2. 金山文档这样玩,效率「狂飙」
  3. 【Faiss】基础索引类型(六)
  4. 计算机网络是通信线路和,计算机网络与通信_冯博文.pdf
  5. Windows拷贝文件到linux上
  6. Windows局域网渗透(IPC$管道)
  7. 一加6t的计算机功能,一加 6T 全面曝光:这款手机好像已经没有太多「秘密」了...
  8. 修改定位服务器,修改定位器服务器地址
  9. 内网穿透实现外网访问内网SQL数据库
  10. 模式分析之:比茶大陆商城分析