forked from improper4/uva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVa00152_TreesaCrowd.java
61 lines (51 loc) · 1.86 KB
/
UVa00152_TreesaCrowd.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package uva;
/* USER: 46724 (sfmunera) */
/* PROBLEM: 88 (152 - Tree's a Crowd) */
/* SUBMISSION: 08518367 */
/* SUBMISSION TIME: 2011-01-18 19:27:06 */
/* LANGUAGE: 2 */
import java.util.*;
public class UVa00152_TreesaCrowd {
public static void main(String[] args) {
try {
Scanner in = new Scanner(System.in);
ArrayList<Integer> X = new ArrayList<Integer>();
ArrayList<Integer> Y = new ArrayList<Integer>();
ArrayList<Integer> Z = new ArrayList<Integer>();
int[] cnt = new int[10];
while (true) {
int x, y, z;
x = in.nextInt();
y = in.nextInt();
z = in.nextInt();
if (x == 0 && y == 0 && z == 0) break;
X.add(x);
Y.add(y);
Z.add(z);
}
for (int i = 0; i < X.size(); ++i) {
double min = Double.MAX_VALUE;
for (int j = 0; j < X.size(); ++j) {
if (i != j) {
int x1 = X.get(i);
int x2 = X.get(j);
int y1 = Y.get(i);
int y2 = Y.get(j);
int z1 = Z.get(i);
int z2 = Z.get(j);
double d = Math.sqrt((x2 - x1) * (x2 - x1) +
(y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1));
min = Math.min(min, d);
}
}
if (min < 10) ++cnt[(int)min];
}
for (int i = 0; i < cnt.length; ++i)
System.out.format("%4d", cnt[i]);
System.out.println();
} catch (Exception e) {
//e.printStackTrace();
System.exit(0);
}
}
}