Kick the ball!(dfs)湖南省赛第十届
Problem K: Kick the ball!
Time Limit: 1 Sec Memory Limit: 128 MB Special Judge
Submit: 109 Solved: 82
[Submit][Status][Web
Board]
Description
"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%
HINT
题意:点球大战,轮流每队点射5个球。A先踢。A、B轮流踢,假设当前比分已经能直接让比赛胜利接下来的球就不须要踢了。问最后的得分是题所给出的得分的概率
思路:暴力DFS,直接枚举哪些球进了哪些球没进,注意比赛提前结束这个特殊的剪枝即可。
链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?
cid=2095&pid=10
#include<stdio.h>
double pi[15];
int x;
int y;
double ans;
bool judge(int a,int b,int t)
{
if(a-b-(t+1)/2>0) return true;//a>b,假设推断的这个点是b点。那么t是奇数须要(t+1)/2,假设是a点t为偶数t/2=(t+1)/2
if(b-a-t/2>0) return true;//b>a,假设推断的这个点是b点,那么t是奇数须要(t+1)/2个求能够胜,可是b>a了。所以假设这球不得分,假设是a点t为偶数t/2=(t+1)/2
return false;
}
void dfs(int a,int b,int k,double p)
{ if(p<1e-6) return ;
if(k==10)
{
// printf("a=%d,b=%d\n",a,b);
if(a==x&&b==y)
ans+=p;
return ;
}
if(judge(a,b,10-k))//推断这一脚要不要踢
{
dfs(a,b,k+1,p);
return ;
}
if(k&1)
{
dfs(a,b+1,k+1,p*pi[k]);
dfs(a,b,k+1,p*(1-pi[k]));
}
else
{
dfs(a+1,b,k+1,p*pi[k]);
dfs(a,b,k+1,p*(1-pi[k]));
}
}
int main()
{
int ca=1;
while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&pi[0],&pi[2],&pi[4],&pi[6],&pi[8],&pi[1],&pi[3],&pi[5],&pi[7],&pi[9])!=EOF)
{ scanf("%d-%d",&x,&y);
// printf("x=%d,y=%d\n",x,y);
ans=0;
dfs(0,0,0,1.0);
printf("Case %d: %.2f%%\n",ca++,ans*100.0);
}
return 0;
}
/*
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
*/
Kick the ball!(dfs)湖南省赛第十届的更多相关文章
- CSU 1505 酷酷的单词 湖南省赛第十届题目
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505 题意:技巧题,就是一行字符串中,每个字母出现的次数互不相同,复即为酷的单词. 解题 ...
- 惨痛第十届蓝桥杯总结(附录蓝桥省赛知识点总结)-C++ B组
虽然目前距离蓝桥省赛仅仅过去一天但昨天下午和大神对答案的感觉依旧..... 现在深刻里理解到了为啥大神老是说咱们蓝桥叫 阅读理解杯(现在我非常认同这种说法啊...) 虽然第一次参加,赛前紧张提前30分 ...
- 2016湖南省赛 I Tree Intersection(线段树合并,树链剖分)
2016湖南省赛 I Tree Intersection(线段树合并,树链剖分) 传送门:https://ac.nowcoder.com/acm/contest/1112/I 题意: 给你一个n个结点 ...
- csu 1503: 点弧之间的距离-湖南省第十届大学生计算机程序设计大赛
这是--比量p并用交点连接中心不上弧.在于:它至p距离.是不是p与端点之间的最短距离 #include<iostream> #include<map> #include< ...
- 第十届蓝桥杯省赛JavaB组个人题解
前言 以下的第十届蓝桥杯Java B组省赛的题目题解只是我个人的题解,提供一些解题思路,仅作参考,如有错误,望大家指出,不甚感激,我会及时更改. 试题 A: 组队 ----- 答案:490 [问题描述 ...
- 第十届蓝桥杯2019年C/C++ 大学B组省赛试题
2019年第十届蓝桥杯大赛软件类省赛C/C++大学B组 试题 A:组队 本题总分:5分 [问题描述] 作为篮球队教练,你需要从以下名单中选出 1号位至 5号位各一名球员, 组成球队的首发阵容. 每位球 ...
- 第十届蓝桥杯2019年C/C++ 大学A组省赛试题
2019年蓝桥杯第十届软件类省赛 C/C++ 大 学 A 组 试题 A: 平方和 本题总分:5 分 [问题描述] 小明对数位中含有 2.0.1.9 的数字很感兴趣,在 1 到 40 中这样的数包括 1 ...
- 2017 湖南省赛 K Football Training Camp
2017 湖南省赛 K Football Training Camp 题意: 在一次足球联合训练中一共有\(n\)支队伍相互进行了若干场比赛. 对于每场比赛,赢了的队伍得3分,输了的队伍不得分,如果为 ...
- 河南省第十届省赛 Plumbing the depth of lake (模拟)
title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...
随机推荐
- 【bzoj3170】[Tjoi 2013]松鼠聚会 旋转坐标系
题目描述 有N个小松鼠,它们的家用一个点x,y表示,两个点的距离定义为:点(x,y)和它周围的8个点即上下左右四个点和对角的四个点,距离为1.现在N个松鼠要走到一个松鼠家去,求走过的最短距离. 输入 ...
- Linux服务器的安装
命令:1. mount /mnt/cdrom/回车 安装光驱2. cd /mnt/cdrom/ 进入光驱目录3. cd /mnt/cdrom/RedHat/RPMS/ 进入RPMS目录4. rpm - ...
- python -- DNS处理模块dnspython
简介 dnspython – 是python实现的一个DNS工具包,利用其查询功能来实现dns的服务监控及解析结果的校验 安装dnspython pip install dnspython 使用 常见 ...
- js 打印二维码
先简单说一下jquery-qrcode,这个开源的三方库(可以从https://github.com/jeromeetienne/jquery-qrcode 获取), qrcode.js 是实现二维码 ...
- Pebbles(hdu 2167)
题意:给定一个N*N的方格,让你在里面取出一些数使其和最大,要求每一个数不能与其相邻的8个数同时取出. /* 和hdu1565差不多,只不过在更新的时候考虑斜上方的格子对该格子的影响. */ #inc ...
- Activation(hdu 4089)
题目:仙5的激活序列.有以下4种情况: 1.注册失败,但是不影响队列顺序 ,概率为p1 2.连接失败,队首的人排到队尾,概率为p2 3.注册成功,队首离开队列,概率为p3 4.服务器崩溃,激活停止,概 ...
- JS函数(自调函数)与闭包【高级函数】
JavaScript:BOM(浏览器对象)+DOM(文档对象)+ECMAScript javascript面向对象: * 概述: * 发展: * 互联网发展对浏览器页面性能或效果要求越来越高,HTML ...
- 【Visual Studio】error: /ZI”和“/Gy-”命令行选项不兼容(转)
原文转自 http://bbs.100home.net/view/4206.html [问题说明]vc6项目用vs2015打开时遇到的错误 [解决方法]项目属性->c/c++->常规-&g ...
- hdu 5438(类似拓扑排序)
Ponds Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Sub ...
- 关于TS返回 Can't use function return value in write context 问题
在项目开发过程中,出现某一接口文件间歇性出现500错误,间歇性出现说明是有条件才会产生,查看错误日志显示:Fatal error: Can't use function return value in ...