将每个点与x正半轴夹角利用atan求出来,都在[0,360)之间
然后排序,枚举夹角相邻的两个点,ans=min(360-(the[i+1]-the[i])) 1<=1<n
注意最后判断下第一条和最后一条之间夹角
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 #include2 #include 3 #include 4 #include 5 #define eps 1e-10 6 using namespace std; 7 double the[100005]; 8 int main() 9 {10 int n,i;11 double x,y,minx;12 scanf("%d",&n);13 for (i=1;i<=n;i++)14 {15 scanf("%lf%lf",&x,&y);16 if (x==0) {17 if (y>0) the[i]=90;18 else the[i]=270;19 }20 else{21 the[i]=atan(y/x)*180/3.141592653579793;22 if (fabs(the[i])<=eps){23 if (x<0) the[i]=180;24 }25 else if (the[i]<=eps) {26 if (x>0) the[i]+=360;27 else the[i]+=180;28 }29 else if (x<0) the[i]+=180;30 }31 }32 sort(the+1,the+n+1);33 minx=the[n]-the[1];34 for (i=1;i
题目链接: