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 |
0?#include<iostream> #include<iomanip> #include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<utility> using namespace std; typedef pair<double,double> xypnt; int T; int n; istream& operator>>(istream& my,xypnt& p){ my>>p.first>>p.second; return my; } xypnt a[100010],b[100010]; double minn=static_cast<double>(INT_MAX); inline double dist(int i,int j){ xypnt x=a[i],y=b[j]; return sqrt((x.first-y.first)*(x.first-y.first) + (x.second-y.second)*(x.second-y.second)) ; } int main(){ cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;++i) cin>>*(a+i); for(int i=1;i<=n;++i) cin>>*(b+i); sort(a+1,a+1+n); sort(b+1,b+1+n); for(int i=1;i<=n;++i){ for(int j=1;j<=n;++j){ double now=dist(i,j); if(now>minn)break; minn=now; } } cout<<fixed<<setprecision(3)<<minn<<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