How to transform the circular domain problem into the interval intersection problem
This article mainly introduces "how to transform the circular domain problem into the problem of interval intersection". In daily operation, I believe many people have doubts about how to transform the circular domain problem into the problem of interval intersection. The editor consulted all kinds of data and sorted out simple and easy operation methods. I hope to help you answer the doubt of "how to transform the circular domain problem into the problem of interval intersection"! Next, please follow the small series to learn together!
The problem of circle domain is transformed into the problem of intersection of intervals.
(Use the right endpoint as a criterion-it is easier to cover the next paragraph)
#include#include#include#include#includeusing namespace std;const int N=1010;int n,d;struct Segment{ double l,r; //overloaded operator bool operator
< (const Segment& t)const{ return r>n>>d; for(int i=0;id) failed=true; else{ //interval length double len=sqrt(d*d-y*y); seg[i].l=x-len; seg[i].r=x+len; } } if(failed) puts("-1"); else{ //interval right endpoint sort sort(seg,seg+n); int res=0; double last=-1e20; for(int i=0;i