The main topic: give some points on the plane, now let you use a long axis and x axis into a certain angle, long axis: the short axis known ellipse to cover all coordinates, to find the smallest short axis length.
Idea: Obviously, the shape and placement state of this ellipse has been given, but there is no way to find the smallest drag circle cover ah. Transforms the ellipse into a circle using coordinate transformations. Let's start by making the long axis parallel to the x axis and rotate all the points on the plane to this angle. Then only the x-coordinate of all points is divided by the long axis: the short axis is available. The rest is the smallest round cover.
Note: Coordinate rotation formula:
X ' = x * cos (a)-Y * sin (a)
Y ' = x * sin (a) + y * cos (a)
CODE:
#define _crt_secure_no_warnings#include <cmath> #include <cstdio> #include <cstring> #include < iomanip> #include <iostream> #include <algorithm> #define MAX 50010#define PI (ACOs ( -1.0)) using namespace Std;struct point{double x, y; Point (Double _,double __): X (_), Y (__) {}point () {}point operator + (const-point &a) const {return-point (x + a.x,y + a.y); }point operator-(const point &a) const {return point (X-A.X,Y-A.Y);} Point operator * (double A) const {return point (x * a,y * a);} void Read () {scanf ("%lf%lf", &x,&y);}} Point[max];inline Double Cross (const point &p1,const point &p2) {return p1.x * p2.y-p1.y * p2.x;} Inline double Calc (const point &p1,const point &p2) {return sqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P 1.Y-P2.Y));} Inline point Mid (const-point &p1,const-&P2) {return point (p1.x + p2.x)/2, (P1.Y + p2.y)/2);} Inline point Change (const point &v) {return point (-v.y,v.x);} inline void Rotate (point &p,double Alpha) {p = point (p.x * cos (alpha)-p.y * sin (Alpha), p.x * sin (Alpha) + p.y * cos (alpha)); struct Circle{point o;double R; Circle (const point &_,double __): O (_), R (__) {}bool incircle (const point &p) {return Calc (o,p) <= R;}}; struct Line{point p,v; Line (const point &_,const point &__):p (_), V (__) {}};inline-point getintersection (const line &l1,const line &A MP;L2) {Point u = l1.p-l2.p;double t = Cross (L2.V,U)/Cross (L1.V,L2.V); return L1.P + l1.v * t;} int points;double A,p;int Main () {cin >> points;for (int i = 1; I <= points; ++i) Point[i]. Read (); Cin >> a >> p;random_shuffle (point + 1,point + points + 1), for (int i = 1; I <= points; ++i) {Rotate ( Point[i], (1-A/N) * 2 * PI);p oint[i].x/= p;} Circle Now (point[1],.0), for (int i = 2; I <= points; ++i) if (!now. InCircle (Point[i])) {now = Circle (point[i],.0), for (int j = 1; j < i; ++j) if (!now. InCircle (Point[j])) {now = Circle (Mid (Point[i],point[j]), Calc (Point[i],point[j])/2);int k = 1; K < J; ++K) if (!now. InCircle (Point[k]) {line L1 (Mid (Point[i],point[j]), change (Point[j]-point[i]); Line L2 (Mid (point[j],point[k]), change (Point[k]-point[j]); Point intersection = Getintersection (L1,L2), now = Circle (Intersection,calc (Intersection,point[i]));}}} cout << Fixed << setprecision (3) << NOW.R << Endl;return 0;}
Bzoj 3564 SHOI 2014 signal Growth Meter coordinate transformation + minimum circle coverage