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<<N); i++) dp[i]=l; - Doublecn1=l; in for(intI=0; i< (1<<N); i++) - { toans=Max (ans,dp[i]); + for(intj=0; j<n; J + +) - { the if((i& (1<<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<<J)]=R; $ Continue; $ } -Dp[i| (1<<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