Football on Table
Test instructions: Some of the poles on someone, people have a width, and then now there's a ball that shoots past, asking the ball not to bump into anyone's probability
Idea: Calculate the probability of each rod, after the multiplicative, calculate the probability of the bar, you can first the interval length of each person will be covered in the process of how much length accumulated, and then(1?Totaland the/can beMoveMovingDistanceaway from)is the probability of not hitting it.
Code:
#include <stdio.h>#include <string.h>#include <math.h>Const DoubleEPS =1e-8;intT, N;DoubleL, W, x, y, dx, dy;structGan {DoubleLenintNumDoubler[ the];Doubled[ the];DoubleSUMD;voidInit () {SUMD =0;memset(R,0,sizeof(r));memset(d,0,sizeof(d)); }} G;DoubleCal (Gan g) {Doubleyy = G.len * dy/dx + y;DoubleYi = w-g.sumd;DoubleDown =0, up = g.r[0];DoubleAns =0; for(inti =0; i < G.num; i++) {if(up + yi > yy && down < yy) {if(Up > yy) {if(Down + yi > yy) ans + = Yy-down;ElseAns + = Yi; }Else{if(Down + yi > yy) ans + = g.r[i];ElseAns + = Yi-(yy-up); }} down = up + g.d[i]; up = down + g.r[i +1]; }return 1.0-Ans/yi;}intMain () {intCAS =0;scanf("%d", &t); while(t--) {DoubleAns =1;scanf("%LF%LF", &l, &w);scanf("%LF%LF%LF%LF", &x, &y, &DX, &dy);scanf("%d", &n); for(inti =0; I < n; i++) {g.init ();scanf("%lf%d", &g.len, &g.num); for(intj =0; J < G.num; J + +) {scanf("%LF", &g.r[j]); G.SUMD + = G.r[j]; } for(intj =0; J < G.num-1; J + +) {scanf("%LF", &g.d[j]); G.SUMD + = G.d[j]; } G.d[g.num-1] =0; Ans *= cal (g); }printf("Case #%d:%.5lf\n", ++cas, ans); }return 0;}