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)湖南省赛第十届的更多相关文章

  1. CSU 1505 酷酷的单词 湖南省赛第十届题目

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505 题意:技巧题,就是一行字符串中,每个字母出现的次数互不相同,复即为酷的单词. 解题 ...

  2. 惨痛第十届蓝桥杯总结(附录蓝桥省赛知识点总结)-C++ B组

    虽然目前距离蓝桥省赛仅仅过去一天但昨天下午和大神对答案的感觉依旧..... 现在深刻里理解到了为啥大神老是说咱们蓝桥叫 阅读理解杯(现在我非常认同这种说法啊...) 虽然第一次参加,赛前紧张提前30分 ...

  3. 2016湖南省赛 I Tree Intersection(线段树合并,树链剖分)

    2016湖南省赛 I Tree Intersection(线段树合并,树链剖分) 传送门:https://ac.nowcoder.com/acm/contest/1112/I 题意: 给你一个n个结点 ...

  4. csu 1503: 点弧之间的距离-湖南省第十届大学生计算机程序设计大赛

    这是--比量p并用交点连接中心不上弧.在于:它至p距离.是不是p与端点之间的最短距离 #include<iostream> #include<map> #include< ...

  5. 第十届蓝桥杯省赛JavaB组个人题解

    前言 以下的第十届蓝桥杯Java B组省赛的题目题解只是我个人的题解,提供一些解题思路,仅作参考,如有错误,望大家指出,不甚感激,我会及时更改. 试题 A: 组队 ----- 答案:490 [问题描述 ...

  6. 第十届蓝桥杯2019年C/C++ 大学B组省赛试题

    2019年第十届蓝桥杯大赛软件类省赛C/C++大学B组 试题 A:组队 本题总分:5分 [问题描述] 作为篮球队教练,你需要从以下名单中选出 1号位至 5号位各一名球员, 组成球队的首发阵容. 每位球 ...

  7. 第十届蓝桥杯2019年C/C++ 大学A组省赛试题

    2019年蓝桥杯第十届软件类省赛 C/C++ 大 学 A 组 试题 A: 平方和 本题总分:5 分 [问题描述] 小明对数位中含有 2.0.1.9 的数字很感兴趣,在 1 到 40 中这样的数包括 1 ...

  8. 2017 湖南省赛 K Football Training Camp

    2017 湖南省赛 K Football Training Camp 题意: 在一次足球联合训练中一共有\(n\)支队伍相互进行了若干场比赛. 对于每场比赛,赢了的队伍得3分,输了的队伍不得分,如果为 ...

  9. 河南省第十届省赛 Plumbing the depth of lake (模拟)

    title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...

随机推荐

  1. 【NOIP2016】愤怒的小鸟 搜索

    题目描述 Kiana 最近沉迷于一款神奇的游戏无法自拔. 简单来说,这款游戏是在一个平面上进行的. 有一架弹弓位于 (0,0)(0,0) 处,每次 Kiana 可以用它向第一象限发射一只红色的小鸟,小 ...

  2. javascript学习笔记 - 引用类型 Object

    引用类型是一种数据结构,也称作对象定义,类似于类的概念. 对象是引用类型的实例. javascript引用类型有:Object, Array, Date, RegExp, Function 使用new ...

  3. 为什么在header 和 session 之前不能有输出

    1.在header输出之前有输出内容的话,就会造成对header的错误理解(尽管现在已经能容错了),例如不是满足“keyword: value\n”的格式还好,直接错误了,但是满足“keyword: ...

  4. Spring整合Junit进行单元测试

    I. 加入依赖包 Spring Test (如spring-test-2.5.4.jar) JUnit 4 Spring 其他相关包 II.新建Junit Test Case III.读取配置文件 @ ...

  5. Educational Codeforces Round 10——B. z-sort

    B. z-sort time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  6. 洛谷P3327 [SDOI2015]约数个数和 【莫比乌斯反演】

    题目 设d(x)为x的约数个数,给定N.M,求\(\sum_{i = 1}^{N} \sum_{j = 1}^{M} d(ij)\) 输入格式 输入文件包含多组测试数据.第一行,一个整数T,表示测试数 ...

  7. 刷题总结——分配笔名(51nod1526 trie树)

    题目: 班里有n个同学.老师为他们选了n个笔名.现在要把这些笔名分配给每一个同学,每一个同学分配到一个笔名,每一个笔名必须分配给某个同学.现在定义笔名和真名之间的相关度是他们之间的最长公共前缀.设笔名 ...

  8. 【POJ3498】March of the Penguins(最大流,裂点)

    题意:在靠近南极的某处,一些企鹅站在许多漂浮的冰块上.由于企鹅是群居动物,所以它们想要聚集到一起,在同一个冰块上.企鹅们不想把自己的身体弄湿,所以它们在冰块之间跳跃,但是它们的跳跃距离,有一个上限.  ...

  9. 【CF559C】 Gerald and Giant Chess(计数,方案数DP,数论)

    题意:给出一个棋盘为h*w,现在要从(1,1)到(h,w),其中有n个黑点不能走,问有多少种可能从左上到右下 (1 ≤ h, w ≤ 105, 1 ≤ n ≤ 2000),答案模10^9+7 思路:从 ...

  10. netsh配置Windows防火墙(advfirewall)

    有人可能会说,Windows防火墙有非常友好的用户界面,为什么要使用命令行界面来配置一个Windows防火墙?有 个人认为有一下原因(撇开有的人喜欢命令行不喜欢界面的 , o(∩_∩)o 哈哈) Fi ...