#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef struct tree{
int x,y,z;
};
double dis(tree a,tree b)
{
double i,j,k,sum;
i=a.x-b.x;
j=a.y-b.y;
k=a.z-b.z;
sum=i*i+j*j+k*k;
return sqrt(sum);
}
int Statistic(tree a[],int b[],int n)
{
int i,tag=0,j;
double count;
for(j=0;j<n;j++)
{
count=100000;
for(i=0;i<n;i++)
{
if(i!=j)
{
if(dis(a[j],a[i])<count)count=dis(a[j],a[i]);
}
}
if(count<1)b[0]++;
else if(count<2)b[1]++;
else if(count<3)b[2]++;
else if(count<4)b[3]++;
else if(count<5)b[4]++;
else if(count<6)b[5]++;
else if(count<7)b[6]++;
else if(count<8)b[7]++;
else if(count<9)b[8]++;
else if(count<10)b[9]++;
}
return 0;
}
int main()
{
freopen("152in.txt","r",stdin);
freopen("152out.txt","w",stdout);
tree area[5500];
int histogram[10],tag=0,i;
for(i=0;i<10;i++)histogram[i]=0;
while(scanf("%d%d%d",&area[tag].x,&area[tag].y,&area[tag].z))
{
tag++;
if((area[tag-1].x+area[tag-1].y+area[tag-1].z)==0)break;
}
tag--;
Statistic(area,histogram,tag);
for(i=0;i<10;i++)printf("%4d",histogram[i]);
printf("\n");
return 0;
}
UVA - 152 - Tree's a Crowd
最新推荐文章于 2016-08-20 01:52:51 发布