Link
gives you a circle and a point, and lets you draw a circle within the given circle such that the answer circle cannot contain the given point, and that minimizes the area of the given circle not covered by the answer circle. Just output the center and radius of the answer circle.
Analysis: Consider three cases:
when the point is outside the circle:
then the given circle meets the conditions, and the center and coordinates of the circle can be output directly
When the given point and the center of the circle coincide:
the coordinates at this time are (x1+r /2,y1), the radius is r/2
when the given point is inside the circle:
The radius is easy to find, the center of the circle must be found with a similar triangle, and it is difficult to find the intersection of the straight line and the circle all the time during the competition.
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
using namespace std;
const int N=1e7+100;
double dis(double x1,double y1,double x2,double y2)
{
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
int main()
{
double r,x1,x2,y1,y2;
cin>>r>>x1>>y1>>x2>>y2;
double len=dis(x1,y1,x2,y2);
if(len>=r*r)
cout<<x1<<' '<<y1<<' '<<r<<endl;
else if(x1==x2&&y1==y2)
cout<<x1+r/2<<" "<<y1<<' '<<r/2<<endl;
else
{
double Z=sqrt(len);
double R=(Z+r)/2;
cout<<(x1-x2)*R/Z+x2<<' '<<(y1-y2)*R/Z+y2<<' '<<R<<endl;
}
return 0;
}