uva 152 Tree's a Crowd

题意:题意:给你一组三维空间中的点,每个点到其它点都有个距离,其中有个最小距离,如果这个最小距离小于10,就将对应的距离的点个数加1,最后输出距离为0,1,2...8,9的点的个数。(from 百度) 老实说,上面这题意也讲的不明不白,其实这题非常水,就是对每个点进行判断,找出和其他点最短的距离,在下标为该距离的数组上+1,最后输出数组下标0-9的数。 trick:其实最小距离大于9的就不用存放了,只要开个大小10的数组。(不会概括。。。抄的别人的)

好坑啊。。。最后要多一个换行。。不然会WA...题目中又木有说。。。WA到死了好么。。。。

/* ***********************************************
Author :111qqz
Created Time :2016年01月21日 星期四 00时08分50秒
File Name :uva/152.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#include <cassert>
14#define fst first
15#define sec second
16#define lson l,m,rt<<1
17#define rson m+1,r,rt<<1|1
18#define ms(a,x) memset(a,x,sizeof(a))
19typedef long long LL;
20#define pi pair < int ,int >
21#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6const int N=5E3+11;
 7int n;
 8int cnt;
 9int ans[30];
10int dblcmp( double d)
11{
12    return d<-eps?-1:d>eps;
13}
14struct point 
15{
16    int x,y,z;
1    int dis(point q)
2    {
3	int res = (x-q.x)*(x-q.x)+(y-q.y)*(y-q.y)+(z-q.z)*(z-q.z);
4	return  (int)sqrt(res);
5    }
1}p[N];
2int main()
3{
4	#ifndef  ONLINE_JUDGE 
5	freopen("code/in.txt","r",stdin);
6  #endif
	ms(ans,0);
	cnt =  0;
1	while (scanf("%d%d%d",&p[cnt].x,&p[cnt].y,&p[cnt].z)!=EOF)
2	{
3	    if (p[cnt].x==0&&p[cnt].y==0&&p[cnt].z==0) break;
4	    cnt++;
5	}
1	for ( int i = 0 ; i < cnt ; i++)
2	{
3	    int mind = 10000;
4	    for ( int j = 0 ; j < cnt ; j++)
5	    {
6		if (i==j) continue;
7		int tmp = p[i].dis(p[j]);
1		if (tmp<mind)
2		{
3		    mind = tmp;
4		}
1	    }
2		if (mind<10) 	
3		ans[mind]++;
1	}	
2	for ( int i = 0 ; i < 10 ; i++)
3	printf("",ans[i]);
4	printf("\n");
1  #ifndef ONLINE_JUDGE  
2  fclose(stdin);
3  #endif
4    return 0;
5}