Consider a circle in the plane.
You are given an int places. This is the number of places that are equally spaced along the perimeter of the circle, i.e., the distance between any two consecutive places is equal.
The places are numbered 0 to places-1 in clockwise order, starting at an arbitrary place.
We will now draw red points in some of the places. The number of red points is given as an int points. As the number of points may be large, we will generate them using a simple process that is described below.
Finally, once all points are generated, your task is to find and return the number of right triangles that have all three vertices in red points.
To generate the points, you are given three ints a, b, and c.
For n = 0, 1, 2, 3, ..., points-1, execute the following steps:
- Compute P[n] = (a*n*n + b*n + c) modulo places.
- Starting at P[n], find the first place in the clockwise direction that does not contain a red point.
- Put a red point onto that place.
|