// UVa 152 - Tree's a Crowd
#include <iostream>
#include <cmath>
#include <string.h>
#include <stdio.h>
using namespace std;
#define datatype double
struct point {
datatype x, y, z;
};
double dist(point a, point b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z));
}
int main() {
datatype a, b, c;
int n = 0;
cin >> a >> b >> c;
point tree[5000];
while (a != 0 || b != 0 || c != 0) {
tree[n++] = {a,b,c};
cin >> a >> b >> c;
}
int count[10];
memset(count, 0, sizeof(count));
for (int i = 0; i < n; i++) {
datatype mn = 20;
for (int j = 0; j < n; j++)
if (i != j) {
datatype d = dist(tree[i], tree[j]);
if (d < mn)
mn = d;
}
datatype f = floor(mn);
if (f < 10)
count[(int) f]++;
}
for (int i = 0; i < 10; i++)
printf("%4d", count[i]);
printf("\n");
return 0;
}
Saturday, June 6, 2015
UVa 152 - Tree's a Crowd
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment