uva 10245 The Closest Pair Problem_枚举
2014-03-04 23:06
399 查看
题意:求任意两点之间的距离的最少一个距离
思路:枚举一下就可以了
思路:枚举一下就可以了
#include <iostream> #include<cstdio> #include<cmath> using namespace std; #define N 10010 struct node{ double x,y; }p ; int main(int argc, char** argv) { int n,i,j; double mdist,tmp; while(scanf("%d",&n)&&n){ for(i=0;i<n;i++){ scanf("%lf%lf",&p[i].x,&p[i].y); } mdist=0xfffffff; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ tmp=(p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y); mdist=min(mdist,tmp); } } mdist=sqrt(mdist); if(mdist>=10000) printf("INFINITY\n"); else printf("%.4lf\n",mdist); } return 0; }
相关文章推荐
- uva 10245 The Closest Pair Problem_枚举
- UVA-10245 The Closest Pair Problem(最近点对问题)
- UVA - 10245 The Closest Pair Problem
- UVa 10245 - The Closest Pair Problem
- uva 10245 The Closest Pair Problem
- UVa 10245 - The Closest Pair Problem
- UVA - 10245 The Closest Pair Problem
- UVA_10245_ The Closest Pair Problem
- UVA 10245 The Closest Pair Problem (分治法)
- UVA - 10245 The Closest Pair Problem 直接暴力(数据很水)
- UVa 10245 - The Closest Pair Problem
- UVA 10245 The Closest Pair Problem 最近点问题 分治算法
- UVA 10245 The Closest Pair Problem
- UVa 10245 - The Closest Pair Problem
- UVa 10245 - The Closest Pair Problem
- UVA 10245 - The Closest Pair Problem
- uva 10245 The Closest Pair Problem
- UVa 10245 The Closest Pair Problem 分治
- UVA 10245 The Closest Pair Problem(平面最近点对)
- uva 10245 The Closest Pair Problem