BNU 34986 Football on Table
Let's play table football!"
playing table football for hours, we decide to take a rest. And the state of the table remains random, that means each bar is placed at any legal position with equal possibilities (players can’t be outside the table and a bar is fixed at a row).
(If the ball did not touch any player, then I made a goal).
(counted from left to right). And we know the width of each player and the distance between two players. (To simplify the problem, we ignore the thickness of the players, in other words, we consider the players as vertical segments. Then we treat the football
as a point, moving along a straight line and will not touch the boundary of the table).
Input
- The first line contains two numbers L, W (1 ≤ L, W ≤ 108), denoting the length and the width of the table. (the lower left corner of the table is (0, 0) , and the top right corner of the
table is (L, W)). - The second line contains four number X, Y, dx, dy. (X, Y) denotes the initial position of the ball and (dx,
dy) denotes the shooting direction. (X will always be zero, 0 ≤ Y ≤ W, dx> 0). - The third line contains an integer m (1 ≤ m ≤ 10), the number of rows of the players.
- Following m blocks, for the ith block,
- The first line contains a number xi and an integer ai,(0<xi<L,
1 ≤ ai ≤ 100) denoteing the x-coordinate of the ith row and the number of players at the ith row. - The second line contains ai numbers, the jth number wj denotes
the width of the jth (from bottom to top) player at the ith row. - The third line contains ai - 1 numbers, the jth number dj denotes
the distance between the jth player and the (j+1)th player. If ai equals
1, this line will be a blank line.
- The first line contains a number xi and an integer ai,(0<xi<L,
Output
digits after the decimal point, representing the possibility of this shoot turning to a goal, in other words, that the ball does not touch any player.
Sample Input
2
8.0 10.0
0.0 5.0 2.0 -0.1
1
3.0 2
2.0 2.0
1.0
8.0 10.0
0.0 5.0 2.0 0.0
2
3.0 2
2.0 2.0
1.0
4.0 3
2.0 1.0 2.0
1.0 1.0
Sample Output
Case #1: 0.23000
Case #2: 0.13333
Hint
Source
题意::一个人在玩桌面足球,有m行球员。每行球员有ai个,给出每一个球员的宽度和相邻球员之间的距离,球从最左边射出,给出球的起点坐标跟方向向量,问可以到达最右边的概率。
思路:看懂题意就好做点了,枚举每行能够碰到球的距离。然后概率求反
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn = 105; double w[maxn], tail[maxn], pos[maxn]; int main() {
int t, m, cas = 1;
double W, L, X, Y, dx, dy, dis;
scanf("%d", &t);
while (t--) {
double ans = 1.0;
scanf("%lf%lf", &L, &W);
scanf("%lf%lf%lf%lf", &X, &Y, &dx, &dy);
scanf("%d", &m); while (m--) {
double sum = 0.0;
pos[0] = 0.0;
double x;
int n;
scanf("%lf%d", &x, &n);
double y = Y + dy * (x - X) / dx;
for (int i = 0; i < n; i++) {
scanf("%lf", &w[i]);
sum += w[i];
}
tail[0] = w[0];
for (int i = 1; i < n; i++) {
scanf("%lf", &dis);
pos[i] = pos[i-1] + w[i-1] + dis;
tail[i] = pos[i] + w[i];
sum += dis;
}
double cnt = 0.0, len = 0.0;
double mv = W - sum;
for (int i = 0; i < n; i++) {
cnt = 0.0;
if ((pos[i] <= y) && (tail[i] + mv) >= y) {
if (tail[i] >= y)
cnt = (pos[i] + mv <= y) ? mv : (y - pos[i]);
else cnt = (pos[i] + mv >= y) ? w[i] : (tail[i] - y + mv);
}
len += cnt;
}
if (mv == 0.0) {
ans = 0;
break;
}
else ans = ans * (mv - len) / mv;
} printf("Case #%d: %.5lf\n", cas++, ans);
}
return 0;
}
BNU 34986 Football on Table的更多相关文章
- bnu 34986 Football on Table(数学+暴力)
pid=34986" target="_blank" style="">题目连接:bnu 34986 Football on Table 题目大 ...
- 2014 ACM/ICPC 北京邀请赛 部分 题解
题目链接:http://acm.bnu.edu.cn/bnuoj/problem.php?search=2014+ACM-ICPC+Beijing+Invitational+Programming+C ...
- 美国政府关于Google公司2013年度的财务报表红头文件
请管理员移至新闻版块,谢谢! 来源:http://www.sec.gov/ 财务报表下载↓ 此文仅作参考分析. 10-K 1 goog2013123110-k.htm FORM 10-K UNIT ...
- React 篇 Search Bar and content Table
我们要构建一个模块,其中包含一个内容显示的表格,然后上面有一个提供Search的栏位,并对Search中输入栏进行监听,当有改变的时候,触发Search然后对内容表中的内容进行过滤. Demo Lin ...
- python 之 前端开发(form标签、单选框、多选框、file上传文件、按钮、label标签、下拉列表、textarea标签、fieldset标签、table标签)
11.25 form标签 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- 散列表(hash table)——算法导论(13)
1. 引言 许多应用都需要动态集合结构,它至少需要支持Insert,search和delete字典操作.散列表(hash table)是实现字典操作的一种有效的数据结构. 2. 直接寻址表 在介绍散列 ...
- React使用antd Table生成层级多选组件
一.需求 用户对不同的应用需要有不同的权限,用户一般和角色关联在一起,新建角色的时候会选择该角色对应的应用,然后对应用分配权限.于是写了一种实现的方式.首先应用是一个二级树,一级表示的是应用分组,二级 ...
- 创建几个常用table展示方式插件
这次和大家分享的是自己写的一个table常用几种展示格式的js插件取名为(table-shenniu),样式使用的是bootstrap.min.css,还需要引用jquery.min.js包,这个插件 ...
- html中table边框属性
1.向右(横向)合并: <td colspan="5"><span>后台管理系统</span></td> 2.向下(纵向)合并: & ...
随机推荐
- Building a Space Station(bfs)
http://poj.org/problem?id=2031 题意:给出n个球的圆心坐标x,y,z, 半径r,若任意两球不相交,则在两球间建桥.问需建桥的最短距离是多少. 思路:建图,以两球间相差的距 ...
- B - Bit++
Problem description The classic programming language of Bitland is Bit++. This language is so peculi ...
- 微信小程序特殊字符转义方法——&转义&等等
在我编写公司小程序的过程中,有一次在网页端添加了一张图片,结果在小程序端访问失败了,究其原因,竟然是因为该图片名称中有一个“&”符号,网页端添加后,自动转义成了“&”存储到了数据库.当 ...
- lua 10进制转换成其它进制table表示
-- params@num integer -- ~) 默认为10 -- NOTE:先不输出符号 function NumberToArray(num, radix) if type(num) ~= ...
- C++编译错误fatal error C1004: 发现意外的文件尾
出现这种情况就是类或者结构体的定义后面没有加“;”导致的. 而且这种问题好难排查.
- [Intermediate Algorithm] - Binary Agents
题目 传入二进制字符串,翻译成英语句子并返回. 二进制字符串是以空格分隔的. 提示 String.charCodeAt() String.fromCharCode() 测试用例 binaryAgent ...
- Vue 爬坑之路—— 使用 Vuex + axios 发送请求
Vue 原本有一个官方推荐的 ajax 插件 vue-resource,但是自从 Vue 更新到 2.0 之后,官方就不再更新 vue-resource 目前主流的 Vue 项目,都选择 axios ...
- jupyter notebook主目录修改
转自http://blog.csdn.net/c437yuyang/article/details/54836303 1.打开 cmd 输入命令 jupyter notebook --generate ...
- LA 4327
Panagola, The Lord of city F likes to parade very much. He always inspects his city in his car and e ...
- Linux目录与相关配置文件讲解
linux目录介绍及配置文件详细介绍 重要目录简介 目录名 作用 boot 与电脑启动相关,推荐单独分区. etc 存放配置文件 mnt 一般用来设置挂载点 src.sys.proc 与系统内核相关, ...