### Problem Statement

NOTE: This problem statement contains subscripts and superscripts which may not display properly for plugin users.

Write a program to generate a list of random 3D points in space, and then compute the distance between the pair of closest points. Also determine how many distinct pairs of points are this exact distance apart.

Generate the random points using the following pseudo-random number generator. Starting with a given seed0:

```    seedi+1 = (seedi * 16807) mod (231-1)
```

The ith random number (starting at i = 1) is given by:

```    randi = (seedi mod (2 * range)) - range
```

The 3D points are triples of 3 successive random numbers:

```    (rand1, rand2, rand3)
(rand4, rand5, rand6)
(rand7, rand8, rand9)
(rand10, rand11, rand12)
etc...
```

You will be given an initial seed, the range, and N (the number of points). The random numbers produced by the generator will be between -range and range-1, inclusive. Return a int[] with two elements: the first element should be the square of the distance between the pair of closest points, and the second element should be the number of distinct pairs of points that have this same squared distance.

NOTE: Be sure to use 64-bit arithmetic for the multiply and mod in the random-number generator, and for computing squared distances.

### Definition

 Class: ClosestPoints Method: distance Parameters: int, int, int Returns: int[] Method signature: int[] distance(int N, int range, int seed) (be sure your method is public)

### Notes

-Ignore any duplicate points. (See example 1.)
-There will be at least 2 unique points.

### Constraints

-N will be between 2 and 150000, inclusive.
-range will be between 1 and 1000000, inclusive.
-seed will be between 1 and 1000, inclusive.
-The square of the distance of the closest pair of points will be less than 1000000000.

### Examples

0)

 `3` `100` `1`
`Returns: { 9163,  1 }`
 The three points are: (-93, -51, -27), (-42, 30, -28), and (44, -22, 23). The closest pair of points are the first and third, and the square of their distance is 9163. There is 1 pair of points with a squared distance of 9163.
1)

 `10000` `1` `7`
`Returns: { 1,  12 }`
 With a range of -1 to 0, there are only 8 possible points. Ignoring duplicates, all 8 possible points are present, forming a 2x2x2 cube. The closest pairs of points are 1 unit apart, and there are 12 such pairs.
2)

 `25` `1` `12`
`Returns: { 1,  9 }`
 This is similar to the previous example, except that only 7 of the 8 possible points exist.
3)

 `15` `5` `504`
`Returns: { 5,  2 }`
4)

 `50000` `1000000` `75`
`Returns: { 1252249,  1 }`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=2890

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5074&pm=2890

legakis

#### Testers:

lbackstrom , brett1479

Geometry