Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求角度就行了~#include<iostream> #include<queue> #include<cstdio> #include<algorithm> #include<cstring> #include<iomanip> #include<map> #include<cstdlib> #include<cmath> #include<vector> #define LL long long #define IT __int64 #define zero(x) fabs(x)<eps #define mm(a,b) memset(a,b,sizeof(a)) const int INF=0x7fffffff; const double inf=1e8; const double eps=1e-10; const double PI=acos(-1.0); const int Max=20001; using namespace std; int sign(double x) { return (x>eps)-(x<-eps); } typedef struct NODE { double x; double y; double r; void input() { scanf("%lf%lf%lf",&x,&y,&r); } void output() { cout<<x<<" "<<y<<" "<<r<<endl; } }point; point start,node[Max]; typedef struct LINE { double st; double ed; }Line; Line line[Max],interval[Max]; double xmult(point p0,point p1,point p2) { return(p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y); } double dmult(point p0,point p1,point p2) { return(p1.x-p0.x)*(p2.x-p0.x)+(p1.y-p0.y)*(p2.y-p0.y); } double Distance(point p1,point p2)// 返回两点之间欧氏距离 { return( sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ) ); } bool cmp(Line u,Line v) { return u.st<v.st; } int main() { int n,m,i,j; while(cin>>n&&n) { scanf("%lf%lf",&start.x,&start.y); for(i=0;i<n;i++) { node[i].input(); double L,as1,as2,A,B; L=Distance(start,node[i]); as1=node[i].r/L; A=asin(as1); as2=(start.x-node[i].x)/L; B=asin(as2); line[i].st=start.x-start.y*tan(A+B); line[i].ed=start.x-start.y*tan(B-A); } sort(line,line+n,cmp); double L=line[0].st,R=line[0].ed; m=0; interval[m]=line[0]; //cout<<line[0].st<<" "<<line[0].ed<<endl; for(i=1;i<n;i++) { if(interval[m].ed>=line[i].st) interval[m].ed=max(line[i].ed,interval[m].ed); else { interval[++m]=line[i]; } } for(i=0;i<=m;i++) cout<<setprecision(2)<<setiosflags(ios::fixed)<<interval[i].st<<" "<<interval[i].ed<<endl; cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator