uva 152 Tree's a Crowd
题意:题意:给你一组三维空间中的点,每个点到其它点都有个距离,其中有个最小距离,如果这个最小距离小于10,就将对应的距离的点个数加1,最后输出距离为0,1,2…8,9的点的个数。(from 百度) 老实说,上面这题意也讲的不明不白,其实这题非常水,就是对每个点进行判断,找出和其他点最短的距离,在下标为该距离的数组上+1,最后输出数组下标0-9的数。 trick:其实最小距离大于9的就不用存放了,只要开个大小10的数组。(不会概括。。。抄的别人的)
好坑啊。。。最后要多一个换行。。不然会WA…题目中又木有说。。。WA到死了好么。。。。
1/* ***********************************************
2Author :111qqz
3Created Time :2016年01月21日 星期四 00时08分50秒
4File Name :uva/152.cpp
5************************************************ */
6
7#include <cstdio>
8#include <cstring>
9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#include <cassert>
20#define fst first
21#define sec second
22#define lson l,m,rt<<1
23#define rson m+1,r,rt<<1|1
24#define ms(a,x) memset(a,x,sizeof(a))
25typedef long long LL;
26#define pi pair < int ,int >
27#define MP make_pair
28
29using namespace std;
30const double eps = 1E-8;
31const int dx4[4]={1,0,0,-1};
32const int dy4[4]={0,-1,1,0};
33const int inf = 0x3f3f3f3f;
34const int N=5E3+11;
35int n;
36int cnt;
37int ans[30];
38int dblcmp( double d)
39{
40 return d<-eps?-1:d>eps;
41}
42struct point
43{
44 int x,y,z;
45
46 int dis(point q)
47 {
48 int res = (x-q.x)*(x-q.x)+(y-q.y)*(y-q.y)+(z-q.z)*(z-q.z);
49 return (int)sqrt(res);
50 }
51
52}p[N];
53int main()
54{
55 #ifndef ONLINE_JUDGE
56 freopen("code/in.txt","r",stdin);
57 #endif
58
59 ms(ans,0);
60 cnt = 0;
61
62 while (scanf("%d%d%d",&p[cnt].x,&p[cnt].y,&p[cnt].z)!=EOF)
63 {
64 if (p[cnt].x==0&&p[cnt].y==0&&p[cnt].z==0) break;
65 cnt++;
66 }
67
68
69 for ( int i = 0 ; i < cnt ; i++)
70 {
71 int mind = 10000;
72 for ( int j = 0 ; j < cnt ; j++)
73 {
74 if (i==j) continue;
75 int tmp = p[i].dis(p[j]);
76
77 if (tmp<mind)
78 {
79 mind = tmp;
80 }
81
82 }
83 if (mind<10)
84 ans[mind]++;
85
86 }
87 for ( int i = 0 ; i < 10 ; i++)
88 printf("",ans[i]);
89 printf("\n");
90
91
92
93
94
95 #ifndef ONLINE_JUDGE
96 fclose(stdin);
97 #endif
98 return 0;
99}