- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCandyShop.java
More file actions
Latest commit
39 lines (34 loc) · 861 Bytes
/
Copy pathCandyShop.java
File metadata and controls
39 lines (34 loc) · 861 Bytes
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
// Paste me into the FileEdit configuration dialog
// SRM 508 DIV 2 - 250.0
publicclassCandyShop {
privatestaticfinalintCENTER = 200;
publicintcountProbablePlaces(int[] X, int[] Y, int[] R) {
int[][] map = newint[CENTER * 2 + 1][CENTER * 2 + 1];
for (inti = 0; i < X.length; i++) {
check(map, X[i], Y[i], R[i]);
}
intcount = 0;
for (inti = 0; i < map.length; i++) {
for (intj = 0; j < map[i].length; j++) {
if (map[i][j] == R.length) {
count++;
}
}
}
returncount;
}
privateintabs(intk) {
returnMath.abs(k);
}
privatevoidcheck(int[][] map, intx, inty, intr) {
for (inti = -r; i <= r; i++) {
for (intj = -r; j <= r; j++) {
if (abs(i + x) <= CENTER && abs(j + y) <= CENTER) {
if (abs(i) + abs(j) <= r) {
map[i + x + CENTER][j + y + CENTER]++;
}
}
}
}
}
}