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.向下(纵向)合并: & ...
随机推荐
- 0507-php独立环境的安装与配置
1.在一个纯英文目录下新建三个文件夹 2.安装apache(选择好版本) 过程中该填的按格式填好,其余的只更改安装目录即可 如果报错1901是安装版本的问题. 检查:安装完成后localhost打开为 ...
- [Apple开发者帐户帮助]六、配置应用服务(3)创建地图标识符和私钥
要与MapKit JS通信,您将使用Maps私钥对一个或多个开发人员令牌进行签名. 首先注册地图标识符以识别您的应用.为使用MapKit JS的每个应用注册地图标识符.接下来创建并下载启用了MapKi ...
- DCOM 找不到 office word 的解决方法
1. 在运行里面 输入 comexp.msc -32 2.在“DCOM配置”中,为IIS账号配置操作Word(其他Office对象也一样)的权限. 具体操作:“组件服务(Component ...
- C - Stones on the Table
Problem description There are n stones on the table in a row, each of them can be red, green or blue ...
- Run as ant build每次都执行两次-问题解决
在Eclipse里面,运行ant,整个测试流程总是执行两遍,其几天试了下在DOS命令行直接调用ant, 结果发现只执行了一次,并且内存消耗好像也没那么大了,估计是eclipse自己的问题.问题解决了, ...
- 好用的Cache辅助工具类
话不多说,直接上代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...
- SQLServer2008 将本地excel导入到远程服务器表
--1.创建链接服务器,相当于创建一个访问远程数据库的快捷方式 exec sp_addlinkedserver 'TestLink', ' ', 'SQLOLEDB ', '111.11.1.111' ...
- windows phone传感器
Windows phone中的传感器主要包括加速计传感器.罗盘传感器.陀螺仪传感器等 加速计传感器 Accelerometer类是加速传感器的接口,Accelerometer类位于Windows.De ...
- Excel常用的小技巧
1.Excel如何实现单元格内轻松换行:按住ALT+enter就可以了. 2.Excel固定表头:在“视图”>冻结窗口>冻结首行. 3.防止电脑突然断电,导致正在编辑的Excel数据丢失, ...
- matlab中 注意事项--字符串
Matlab中的字符串操作 原文链接:http://hi.baidu.com/dreamflyman/item/bd6d8224430003c9a5275a9f (1).字符串是以ASCII码形式存储 ...