"Bored?

Let's play table football!"

The table football is played on a rectangular table, usually contains m rows of players which are plastic, metal, wooden, or sometimes carbon-fibre figures mounted on vertical metal bars. After
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).
 
 
Now I'm wondering if the goal-keeper shoot a ball, what’s the possibility of this shoot turning to a goal?

(If the ball did not touch any player, then I made a goal).

Let's assume there is ai players on the ith row
(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 an integer T, which denotes the number of test cases.
For each test case:
  • 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.
We guarantee that ∑wj + ∑dj + 1< W
 

Output

For each case, first output the case number as "Case #x: ", and x is the case number. Then output the result rounded to 5
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

The black solid lines denote the table.
The dashed line denotes the bar.
The gray lines denote the players.
The dot-dashed line denote the trajectory of the ball.
 

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的更多相关文章

  1. bnu 34986 Football on Table(数学+暴力)

    pid=34986" target="_blank" style="">题目连接:bnu 34986 Football on Table 题目大 ...

  2. 2014 ACM/ICPC 北京邀请赛 部分 题解

    题目链接:http://acm.bnu.edu.cn/bnuoj/problem.php?search=2014+ACM-ICPC+Beijing+Invitational+Programming+C ...

  3. 美国政府关于Google公司2013年度的财务报表红头文件

    请管理员移至新闻版块,谢谢! 来源:http://www.sec.gov/ 财务报表下载↓ 此文仅作参考分析. 10-K 1 goog2013123110-k.htm FORM 10-K   UNIT ...

  4. React 篇 Search Bar and content Table

    我们要构建一个模块,其中包含一个内容显示的表格,然后上面有一个提供Search的栏位,并对Search中输入栏进行监听,当有改变的时候,触发Search然后对内容表中的内容进行过滤. Demo Lin ...

  5. python 之 前端开发(form标签、单选框、多选框、file上传文件、按钮、label标签、下拉列表、textarea标签、fieldset标签、table标签)

    11.25 form标签 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  6. 散列表(hash table)——算法导论(13)

    1. 引言 许多应用都需要动态集合结构,它至少需要支持Insert,search和delete字典操作.散列表(hash table)是实现字典操作的一种有效的数据结构. 2. 直接寻址表 在介绍散列 ...

  7. React使用antd Table生成层级多选组件

    一.需求 用户对不同的应用需要有不同的权限,用户一般和角色关联在一起,新建角色的时候会选择该角色对应的应用,然后对应用分配权限.于是写了一种实现的方式.首先应用是一个二级树,一级表示的是应用分组,二级 ...

  8. 创建几个常用table展示方式插件

    这次和大家分享的是自己写的一个table常用几种展示格式的js插件取名为(table-shenniu),样式使用的是bootstrap.min.css,还需要引用jquery.min.js包,这个插件 ...

  9. html中table边框属性

    1.向右(横向)合并: <td colspan="5"><span>后台管理系统</span></td> 2.向下(纵向)合并: & ...

随机推荐

  1. Redis的事务讲解

    1. Redis事务的概念 是什么: 可以一次执行多个命令,本质是一组命令的集合.一个事务中的所有命令都会序列化,按顺序串行化的执行而不会被其他命令插入 能干嘛:一个队列中,一次性.顺序性.排他性的执 ...

  2. 前端面试:问到GET和POST两种区别

    最直观的区别就是GET把参数包含在URL中,POST通过request body传递参数. "标准答案"(本标准答案参考自w3schools): GET在浏览器回退时是无害的,而P ...

  3. 1.java安全框架SHIRO

    1. shiro介绍 Apache Shiro是一个强大且易用的java安全框架,执行身份验证.授权.密码和会话管理. 使用Shiro的易于理解的API,您可以快速.轻松地获得任何应用程序,从最小的移 ...

  4. Vue初级

    来学习vue.js的宝宝们应该都了解了什么是vue并且是有兴趣去学的,我也是自己学习vue,欢迎大家一起讨论. 现在,我么先自己尝试用vue来写个hello world吧. 一.创建一个 .html  ...

  5. 本博客基本不再更新,请移步至我的CSDN博客

    本博客基本不再更新,请移步至我的CSDN博客:http://blog.csdn.net/wpxu08

  6. (转)基于MVC4+EasyUI的Web开发框架经验总结(11)--使用Bundles处理简化页面代码

    http://www.cnblogs.com/wuhuacong/p/4073203.html 在Web开发的时候,我们很多时候,需要引用很多CSS文件.JS文件,随着使用更多的插件或者独立样式文件, ...

  7. React-Router ---withRouter

    import React from 'react' import { withRouter } from 'react-router' const Hello = (props) => { re ...

  8. eoLinker GoKu Gateway 开源版 V2.1发布,加入UI管理系统等

    GoKu API Gateway 是eoLinker旗下的开源版接口网关,支持OpenAPI与微服务管理,支持私有云部署,实现API转发.请求参数转换.数据校验等功能,提供图形化界面管理,能够快速管理 ...

  9. 【剑指Offer】59、按之字形顺序打印二叉树

      题目描述:   请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推.   解题思路:   这道题仍然是二 ...

  10. 【maven】成功生成jar包,提示找不到主类?

    问题描述:   使用maven构建zookeeper项目,完成一个简单的创建组的实例,代码调试完成,使用mvn clean install成功打包得到了jar包,但是在执行时发现使用java -cp ...