bnu 34986 Football on Table(数学+暴力)
2014-06-25 22:08
435 查看
题目连接:bnu 34986 Football on Table
题目大意:给出桌子的大小L,W,然后是球的起始位置sx,sy,以及移动的向量dx,dy,然后给出n,表示有n个杆,对于每个杆,先给出位置x,以及杆上有多少个小人c,给出小人的宽度,再给出c个小人间的距离。现在问说球有多少个概率可以串过所有人。
解题思路;对于每个杆求无阻挡的概率,注意概率 = 空隙 / 可移动的范围大小,而不是W。其他就水水的。
题目大意:给出桌子的大小L,W,然后是球的起始位置sx,sy,以及移动的向量dx,dy,然后给出n,表示有n个杆,对于每个杆,先给出位置x,以及杆上有多少个小人c,给出小人的宽度,再给出c个小人间的距离。现在问说球有多少个概率可以串过所有人。
解题思路;对于每个杆求无阻挡的概率,注意概率 = 空隙 / 可移动的范围大小,而不是W。其他就水水的。
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-8; const int N = 205; double L, W; double sx, sy, dx, dy; double d ; double solve () { int n, c; double w, ans = 1; scanf("%d", &n); while (n--) { scanf("%lf%d", &w, &c); double r = sy + w * dy / dx; double s = 0; c = 2 * c - 1; for (int i = 0; i < c; i += 2) scanf("%lf", &d[i]); for (int i = 1; i < c; i += 2) scanf("%lf", &d[i]); for (int i = 0; i < c; i++) s += d[i]; double l = W - r; double rec = 0; if (l > s) { rec += (l - s); l = 0; } else { l = s - l; } if (r > s) { rec += (r - s); r = s; } s = 0; for (int i = 0; i < c; i++) { double tmp = s + d[i]; if (i&1) { double add = min(r, tmp) - max(s, l); rec += max(add, (double)0); } s = tmp; } ans *= rec / (W-s); } return ans; } int main () { int cas; scanf("%d", &cas); for (int i = 1; i <= cas; i++) { scanf("%lf%lf", &L, &W); scanf("%lf%lf%lf%lf", &sx, &sy, &dx, &dy); printf("Case #%d: %.5lf\n", i, solve()); } return 0; }
相关文章推荐
- bnu 34986 Football on Table(数学+暴力)
- BNU 34986 Football on Table 解题报告(暴力)
- BNU 34986 Football on Table
- BNU 34986 Football on Table
- uva 10620 - A Flea on a Chessboard(暴力+数学)
- 2014北京邀请赛 F Football on Table
- 2014北京邀请赛 F Football on Table
- Football on Table
- 2.无法从用法中推导出方法System.Data.Linq.Table.InsertAllOnSubmit...
- HBase change split policy on an existing table
- zoj1494 暴力模拟 简单数学问题
- hdu 5194 组合数学or暴力
- SET IDENTITY_INSERT [Table] [ON|OFF]
- oracle trigger for table on commit
- CSUOJ 1302 - Walking on Chessboard 暴力BFS
- odi接口抽取数据报错提示Create Unique Index on flow table创建唯一索引失败解决方法
- bnu 10790 Periodic Table of Elements(模拟)
- Add-on Table ‘Enhancement category for table missing’ 警告解决
- zoj1494 暴力模拟 简单数学问题
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D. Innokenty and a Football League