博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
BNU 34986 Football on Table
阅读量:6228 次
发布时间:2019-06-21

本文共 4126 字,大约阅读时间需要 13 分钟。

"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 a
i players on the i
th 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 ∑w
j + ∑d
j + 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

28.0 10.00.0 5.0 2.0 -0.113.0 22.0 2.01.08.0 10.00.0 5.0 2.0 0.023.0 22.0 2.01.04.0 32.0 1.0 2.01.0 1.0

Sample Output

Case #1: 0.23000Case #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 
#include
#include
#include
#include
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; }

转载地址:http://gxtna.baihongyu.com/

你可能感兴趣的文章
django判断checkbox是否选中_django视图层之请求与响应
查看>>
group by 怎么用java对象接收_生产服务宕机,线上业务挂了!Promtheus 怎么又不报警了呢?...
查看>>
himawari-8卫星叶绿素a产品、_走过50年,看“风云”眼中的世界| 卫星看中国特别版...
查看>>
mybatis使用$报空指针_打破你的认知!Java空指针居然还能这样玩,90%人不知道…...
查看>>
windows mysql 重置root密码_在Windows下Mysql如何重置root用户密码
查看>>
mysql5.6 linux下载_mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz下载安装
查看>>
r语言操作mysql_R语言 RMySQL连接操作mysql数据库
查看>>
mysql 整形相除_整型相除截断的技巧
查看>>
mysql备份字符集_浅谈MySQL备份字符集的问题
查看>>
dos下设置mysql密码_dos命令下修改mysql密码的方法
查看>>
交换机如何设置我能访问它但他不能访问我_“交换机”有什么作用?怎样使用?...
查看>>
数据结构基本操作_R中的数据结构简介及类别变量的基本操作
查看>>
微分方程解法总结_视频教学:线性微分方程解的结构、问题类型及求解思路与方法...
查看>>
blt功能_bitblt()用法
查看>>
MySQL中level的用法_leveldb使用 (转载)
查看>>
卷积神经网络由谁提出_科研人员提出一种基于卷积循环神经网络的单通道渐进语音增强方法...
查看>>
python 曲线拟合求参数_Python:查找任意曲线的拟合参数数量
查看>>
python批量生成图片_python日常实用技能:如何利用Python批量生成任意尺寸的图片...
查看>>
python爱好者社区公众号历史文章合集_GitHub - thinkingpy/weixin_crawler: 高效微信公众号历史文章和阅读数据爬虫powered by scrapy...
查看>>
ranger安装hbase插件_ranger的配置与使用
查看>>