标签:nbsp lan const tor scanf using ons tail print
参考了这个博客
#include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; struct point { double x,y; point(){}; point(double _x,double _y) { x=_x,y=_y; } }p,q; struct range { double l,r; bool operator <(const range &a) const { return l<a.l; } }line[505]; double dist(point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } double r; int n,t; int main() { while (scanf("%d",&n)!=EOF && n) { scanf("%lf%lf",&p.x,&p.y); for (int i=1;i<=n;i++) { scanf("%lf%lf%lf",&q.x,&q.y,&r); double d=dist(p,q); double a=asin(r/d),b=asin((p.x-q.x)/d); // printf("a:%lf b:%lf\n",a,b); line[i].r=p.x-p.y*tan(b-a); line[i].l=p.x-p.y*tan(a+b); // printf("%d : %lf~%lf\n",i,p.y*tan(b-a),p.y*tan(b+a)); } sort(line+1,line+1+n); double L=line[1].l,R=line[1].r; for (int i=2;i<=n;i++) { if (line[i].l>R) { printf("%.2f %.2f\n",L,R); L=line[i].l,R=line[i].r; } else R=max(R,line[i].r); } printf("%.2f %.2f\n\n",L,R); } return 0; }
标签:nbsp lan const tor scanf using ons tail print
原文地址:http://www.cnblogs.com/mrsheep/p/8011574.html