iOS gets the current view first responder

Source: Internet
Author: User

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, &AMP;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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.