CF D Bear and Floodlight

Source: Internet
Author: User

Test instructions: There are n lights, each light has a lighted angle, now from the point (l,0) go to the right (r,0), ask if this person has been the lamp according to how far can go?

The pressure DP is then rotated by a vector to find the vector formed by the point (dp[i[,0) with the coordinates of the lamp (P[J].X,P[J].Y) and then rotates the angle p[j].a, resulting in a point on the X axis after the rotation, and then with dp[i| ( 1<<J)] Compare updates to find the maximum value and then compare it to the right endpoint. In one case, when you rotate a vector, you may not have an intersection with the axis, you put the dp[i| ( 1<<J)]=r;

1#include <cstdio>2#include <cmath>3#include <cstring>4#include <algorithm>5 using namespacestd;6 Const DoublePi=acos (-1.0);7 8 intN;9 DoubleL,r;Ten structnode One { A     Doublex, y; -     DoubleA; -}p[ -]; the Doubledp[(1<< -)+Ten]; -  - intMain () - { +       while(SCANF ("%D%LF%LF", &n,&l,&r)! =EOF) -      { +          for(intI=0; i<n; i++) A         { at             DoubleAA; -scanf"%LF%LF%LF",&p[i].x,&p[i].y,&aa); -P[i].a= (Double) (aa*1.0*pi/ the); -         } -          for(intI=0; i< (1&LT;&LT;N); i++) dp[i]=l; -         Doublecn1=l; in          for(intI=0; i< (1&LT;&LT;N); i++) -         { toans=Max (ans,dp[i]); +              for(intj=0; j<n; J + +) -             { the                if((i& (1&LT;&LT;J)) = =0) *                { $                 Doublexx=dp[i]-p[j].x;Panax Notoginseng                 Doubleyy=-p[j].y; -                 DoubleX1=xx*cos (P[J].A)-yy*sin (p[j].a); the                 DoubleY1=xx*sin (P[J].A) +yy*cos (p[j].a); +                 Doublesx=p[j].x+yy* (x1*1.0/y1); A                 if(Sx>r) sx=R; the                 if(y1>=0) +                 { -Dp[i| (1&LT;&LT;J)]=R; $                     Continue; $                 } -Dp[i| (1&LT;&LT;J)]=max (dp[i| (1<<j)],sx); -                } the             } -         }Wuyiprintf"%.10lf\n", Min (ans,r)-l); the      } -      return 0; Wu}
View Code

CF D Bear and Floodlight

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.