uva 152 Tree's a Crowd
2011-09-20 22:38
573 查看
题意:给你空间中的几个点,要你找出与当前点距离最小的点(幸好题意数据量不太大。。)
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; struct node { double a,b,c; }tree[5005]; int a[10]; int main() { int n=0; while(scanf("%lf%lf%lf",&tree .a,&tree .b,&tree .c)!=EOF) { if(tree .a==0&&tree .b==0&&tree .c==0) break; n++; } for(int i=0;i<n;i++) { int imin=1<<29; for(int j=0;j<n;j++) { if(i==j) continue; int temp=sqrt((tree[i].a-tree[j].a)*(tree[i].a-tree[j].a)+ (tree[i].b-tree[j].b)*(tree[i].b-tree[j].b)+ (tree[i].c-tree[j].c)*(tree[i].c-tree[j].c)); imin=min(imin,temp); } a[imin]++; } for(int i=0;i<10;i++) printf("%4d",a[i]); puts(""); return 0; }
相关文章推荐
- uva 152 Tree's a Crowd
- UVa 152 Tree's a Crowd
- UVa:152 - Tree's a Crowd
- UVa 152 - Tree's a Crowd
- UVA 152-Tree's a Crowd(暴力求解三维坐标求最短距离)
- UVA 152 Tree's a Crowd 一堆树 检索水题+暴力
- UVA - 152 Tree's a Crowd
- UVa 152 - Tree's a Crowd
- UVa 152 - Tree's a Crowd解题报告
- UVA - 152 - Tree's a Crowd
- UVa 152 Tree's a Crowd (暴力)
- Uva 152 Tree's a Crowd
- UVA 152 - Tree's a Crowd
- uva - 152 - Tree's a Crowd
- UVA-152 Tree's a Crowd
- uva 152 - Tree's a Crowd
- UVA-152- Tree's a Crowd
- UVA - 152 Tree's a Crowd
- UVa 152 - Tree's a Crowd
- UVA 152 Tree's a Crowd (简单计算)