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.向下(纵向)合并: & ...
随机推荐
- 原生JS---7
原生js学习笔记7——本地存储之cookie操作 什么是cookie • 用来保存页面信息的,如用户名.密码 • cookie的特性:同一个网站中所有的页面共享一套cookie:数量.大小限制:过期时 ...
- 如何通过免费开源ERP Odoo实现企业数字化转型深度分析(一)
本文来自<开源智造企业数字化转型报告白皮书>的精选内容章节.请勿转载.欢迎您反馈阅读意见. 引言 在由消费者驱动的数字经济时代,创新之势锐不可挡.变革步伐从未如此迅速,并且还会越来越快.对 ...
- 【专题系列】单调队列优化DP
Tip:还有很多更有深度的题目,这里不再给出,只给了几道基本的题目(本来想继续更的,但是现在做的题目不是这一块内容,以后有空可能会继续补上) 单调队列——看起来就是很高级的玩意儿,显然是个队列,而且其 ...
- 【Oracle】删除手工创建的数据库
众所周知,DBCA创建的数据库可以通过DBCA命令删除,但是手工创建的数据库却不能用此方式删除,下面给出删除方式: SQL> startup mount exclusive SQL> al ...
- 我的web前端自学之路-心得篇:我为什么要学习web前端?
时光如流水,转眼间,自己已经是大三的学长了,看着一个个学弟学妹,心中有种莫名的感觉,很怀念大学的前两年时光,但也很憧憬着自己的未来,自己将要去经历很多从未经历的事.我是我们学校信科院的一名学生,在编程 ...
- mysql 统计按天、星期、按月数据的各种 sql 语句 (转录)
文章主要是作为知识整理,内容略有修改,方便以后查阅,内容转摘至 陈宇衡的个人博客,欢迎前去围观. 作为演示效果,先创建一个测试表,在插入两条数据(注:时间为 datetime 类型,unix 时间戳需 ...
- ASP.NET MVC5 网站开发实践(一)
一.开发环境 1.开发环境: Visual Studio 2013 2.数据库:Sql Server 2012 3.代码管理:TFS(微软免费提供的) 说明:VS2013与vs2012感觉变化不大,我 ...
- HTML5 video常用属性
一.视频video常用标签方法 <!-- controls 控制条,播放暂停等 controlslist 控制不允许全屏 不允许下载等 poster 封面 autoplay 自动播放 muted ...
- python tips:dict的key顺序
python3.6+版本中,dict的键值保持插入有序. t = list(range(10)) b = t[:] d = dict(zip(t, b)) print(list(d.items())) ...
- ESP32 开发笔记(十二)LittlevGL 添加自定义字体和物理按键
LittlevGL 添加自定义字体获取字库 ttf 文件可以从一些网站上获取字库文件,比如请注意字体许可证 生成源文件使用 LittlevGL 提供的字库文件转换工具,将 ttf 字库文件转换为源文件 ...