#C8441. Counting Points in a Sphere

    ID: 52424 Type: Default 1000ms 256MiB

Counting Points in a Sphere

Counting Points in a Sphere

You are given a sphere centered at the origin with a given diameter d. Your task is to determine the number of points that lie inside, on the surface, or outside the sphere.

Let \( r = \frac{d}{2} \) be the radius of the sphere. A point \((x,y,z)\) is considered to be:

  • Inside the sphere if \( \sqrt{x^2+y^2+z^2} < r \).
  • On the surface if \( \sqrt{x^2+y^2+z^2} = r \).
  • Outside the sphere if \( \sqrt{x^2+y^2+z^2} > r \).

You need to read the input from standard input and write the result to standard output.

Note: Use precise floating point computations to ensure that points exactly on the surface are correctly identified.

inputFormat

The input is given via standard input and has the following format:

d n
x1 y1 z1
x2 y2 z2
... 
xn yn zn

Where:

  • d is a floating point number representing the diameter of the sphere.
  • n is an integer representing the number of points.
  • Each of the next n lines contains three space-separated floating point numbers representing the coordinates of a point.

outputFormat

Output three integers separated by a space, representing the number of points inside the sphere, on the surface of the sphere, and outside the sphere, respectively.

The result should be printed to standard output.

## sample
10.0 4
0 0 0
5 5 5
10 10 10
0 5 5
1 0 3