Zoj 3763--plasma Field (geometry, mathematics) __ Mathematics

Source: Internet
Author: User
Tags square root

Title: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3763

Although the topic is a bit long, read it carefully and find nothing ...

Give a piecewise function R (t) on T:

When 0≤t≤t, R (t) = C*t

When T < t≤t*2, R (t) = c * (T * 2-t). Then for each point (xi,yi), there is a speed (Vx,vy)

Then the distance of the point at T-time (X0,Y0) is expressed in D (t).

The question asks how many points the R (t) =d (T) has on the [0,2t] interval.

Since D (t) directly denotes a square root with a bit of a problem, I use the squares of D (t) and R (t) directly to calculate that all of the following are squared forms.

Make f (t) = d (t)-r (t)

When 0<=t<=t, the known information is given to the F (t) (this can be done on paper, and I am not here to expand):

F (t) = a*t^2 + b*t +c

of which: A = Vx*vx + vy*vy-c*c

B = 2* ((x-x0) *VX + (y-y0) *vy)

C = (x-x0) ^2 + (y-y0) ^2

Then it is to determine whether there are f (T) =0 on [0,t], this high school mathematics has been learned, to find the interval of two of the most value, see if they are different on the line.

As for the maximum value, according to a if is positive, the description can be the minimum value, otherwise the maximum value, the remaining maximum value in two interval endpoints to find the line.

There's no need to control what the two-time function looks like in this range, even if it's not two times, because the monotone function can be considered a special case when the three-point method is used to compute the maximum value.

Then for the interval (t,2*t], the method is similar to the above, except that B will add 4*t*c*c,c to subtract the 4*t*t*c*c, because the formula for R (T) is different now.

PS: At first, it is a positive in the case of the maximum value, WA many times before discovering this has not known how to describe the error. Almost want to open Java write high precision = =

#include <cstdio> const double EPS = 1e-8;
Double x0, y0, C, T;
int n;
Double x, y, VX, VY;
Double A, B, C;
    Double F (Double t) {return a*t*t+b*t+c;} bool Ok_min (double L, double R) {Double low=l, TOP=R, M1, M2;
    Double S1, S2, S3;
        while (top-low>eps) {m1 = low+ (Top-low)/3.0;
        M2 = top-(top-low)/3.0;
        S1 = F (M1);
        S2 = F (m2);
        if (s1<s2) top = m2-eps;
    else low = m1+eps;
    } S1 = F (L);
    S2 = F (R);
    S3 = F (Low);
    if (s1*s3<eps | | s2*s3<eps | | s1*s2<eps) return 1;
else return 0;
    BOOL Ok_max (double L, double R) {Double low=l, TOP=R, M1, M2;
    Double S1, S2, S3;
        while (top-low>eps) {m1 = low+ (Top-low)/3.0;
        M2 = top-(top-low)/3.0;
        S1 = F (M1);
        S2 = F (m2);
        if (s1<s2) low = M1+eps;
    else top = m2-eps;
    } S1 = F (L);
    S2 = F (R);
    S3 = F (Low);
    if (s1*s3<eps | | s2*s3<eps | | s1*s2<eps) return 1; Else   return 0;
    int check () {A = Vx*vx+vy*vy-c*c;
    B = 2.0* ((x-x0) *vx+ (y-y0) *vy);
    C = (x-x0) * (x-x0) + (y-y0) * (Y-Y0);
    if (a<=0) {if (Ok_max (0,t)) return 1;
    } else{if (Ok_min (0,t)) return 1;
    B + = 4.0*t*c*c;
    C-= 4.0*t*t*c*c;
    if (a<=0) {if (Ok_max (t,t*2)) return 1;
    } else{if (Ok_min (t,t*2)) return 1;
return 0;
        int main () {while (~scanf ("%lf%lf%lf%lf", &x0, &y0, &c, &t)) {scanf ("%d", &n);
        int ans=0;
            while (n--) {scanf ("%lf%lf%lf%lf", &x, &y, &AMP;VX, &vy);
        Ans + = check ();
    printf ("%d\n", 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.