TopcoderArchive
Archive
Algorithm problem

CubesInSpheres

Problem statement, definition, constraints, and public examples.

Problem Statement

Given a list of spheres, return the number of 2x2x2 cubes that lie completely inside the intersection of those spheres. The cubes must have sides perpendicular to one of the 3 coordinates axes, the coordinates of all 8 corners must be odd integers, and the edges must be of length 2.

The spheres will be given as four int[] arrays, where x[i], y[i], z[i] give the center of the i-th sphere, and r[i] gives its radius.

If inclusive is 1 then spheres include all points on their surface. If inclusive is 0 then any cube with a corner on the surface of any sphere is not considered to be inside the insersection.

Definition

Class:
CubesInSpheres
Method:
cubes
Parameters:
int[], int[], int[], int[], int
Returns:
long
Method signature:
long cubes(int[] x, int[] y, int[] z, int[] r, int inclusive)
(be sure your method is public)

Constraints

  • x will contain between 1 and 50 elements, inclusive.
  • x, y, z, and r will all contain the same number of elements.
  • Each element of x, y, and z will be between -100000000 and 100000000, inclusive.
  • Each element of r will be between 0 and 100000000, inclusive.
  • inclusive will be between 0 and 1, inclusive.

Examples

    No public sample cases were explicitly marked for this problem in the original data.

    Back to all problems