hdu1007
解题关键:分治算法求解,注意学习分治算法的写法
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #define inf 0x3f3f3f3f 8 using namespace std; 9 typedef long long ll;10 struct point{11 double x,y;12 }p[100002],tmp[100002];13 double dis(point &a,point &b){14 return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));15 }16 bool cmp1(point &a,point &b){17 return a.x >1;26 double d1,d2,d;27 d1=closet(l, mid),d2=closet(mid+1, r);28 d=min(d1,d2);29 int k=0;30 for(int i=l;i<=r;i++){31 if(fabs(p[i].x-p[mid].x) =d) break;37 d=min(d,dis(tmp[i],tmp[j]));38 }39 }40 return d;41 }42 43 44 int main(){45 int n;46 while(scanf("%d",&n)!=EOF){47 if(!n) continue;48 for(int i=0;i
树上分治和数列分治待补。