Topic links
Give a regular polygon of n vertices, give the distance from a point to n vertices within the polygon, and let you find the edge length of the polygon.
The two sides are long, and then the cosine theorem is used to find the angle between the adjacent two sides, see all the added up is not 2Pi.
#include <iostream>#include<vector>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<map>#include<Set>#include<string>#include<queue>#include<stack>#include<bitset>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (i, N, a) for (int i = A; i<n; i++)#defineFi first#defineSe Secondtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };Doublea[104];intMain () {intT, N; CIN>>T; for(intCasee =1; casee<=t; casee++) {printf ("Case %d:", Casee); CIN>>N; for(inti =0; i<n; i++) {scanf ("%LF", &A[i]); } DoubleL =-inf, r =inf; for(inti =0; i<n; i++) {L= Max (L, Fabs (a[i]-a[(i+1)%n])); R= Min (r, a[i]+a[(i+1)%n]); } intFlag =0; while(Fabs (R-L) >EPS) { DoubleMid = (l+r)/2, ans =0; for(inti =0; i<n; i++) { intTMP = (i+1)%O; Ans+ = ACOs ((a[i]*a[i]+a[tmp]*a[tmp]-mid*mid)/(2*a[i]*a[tmp])); } if(Fabs (ans-2*PI) <EPS) {Flag=1; Break; } if(ans>2*PI) R=mid; ElseL=mid; } if(flag) {printf ("%.3f\n", L); } Else{puts ("Impossible"); } } return 0;}
HDU 4033 Regular Polygon Computational geometry dichotomy + cosine theorem