"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. Constructing Roads(spfa)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2493 #include <stdio.h ...

  2. jquery的ajax同步异步执行

    大家先看一段简单的jquery ajax 返回值的js 代码 function getReturnAjax{  $.ajax({    type:"POST",    http:/ ...

  3. Cent OS 6/7 中通过yum安装软件时提示cannot find a valid baseurl...的解决方法

    目录 1 问题描述 2 解决方法一 (Cent OS 7中有效) 3 解决方法二 (Cent OS 7中无效) 1 问题描述 新申请了虚拟机, 系统版本是Cent OS 7.2. 在安装软件的过程中, ...

  4. java热部署

    最近使用java做项目,研究了一下热部署,能够提高工作效率. 需要准备的工具: 1.安装文件http://update.zeroturnaround.com/update-site/ 2.破解 下载破 ...

  5. MessageDigest 加密和解密2

    package com.drawthink.platform.util; import java.security.MessageDigest; import java.security.NoSuch ...

  6. 5.13会话技术Cookie---Session

    .会话技术: 1.会话:一次会话中包含多次请求和相应. 一次会话:浏览器第一次给服务器资源发送请求,会话建立,直到有一方断开为止 2.功能:在一次会话的范围内的多次请求间,共享数据 3.方式: 1.客 ...

  7. python--4、装饰器

    装饰器(Decorator) 使用场景:为被装饰器装饰的函数增加功能,但又不希望修改函数的定义,即在代码运行期间动态增加功能. 装饰器更多的用于后期功能升级而不是编写新的代码.装饰器不光能装饰函数,也 ...

  8. 关于MYSQL 存储过程的文章摘录

    1.      存储过程简介   我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集,经编译后存储 ...

  9. HDU_1517_博弈(巧妙规律)

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  10. Django_文件上传

    使用Django框架实现文件上传功能    upload.html <!DOCTYPE html> <html lang="en"> <head> ...