Problem Statement | |||||||||||||
We are given a disc of radius discRadius and want to cover it using numDiscs small discs - i.e., place the small discs flat above the original disc in such a way that no point of the original disc is visible (assuming the small discs are opaque). All smaller discs we use for the covering have the same radius. We perform the covering using the following procedure:
In summary, we have the freedom to choose the number and size of the rings that the original disc is split into, how many of the numDiscs discs are used for covering each of the rings, and the distance from the center at which the small discs for each ring are placed. We will have to choose these parameters such that a covering using this procedure is possible using the smallest possible discs. Given discRadius, the radius of the original disc, and numDiscs, the total number of small discs to use, return the minimum radius that the small discs must have so that a covering using the above procedure is possible. The example shown above is only one possibility to cover the original disc using 19 small discs (which turns out to be the optimal one for the used procedure). The figure below shows as an example another (non-optimal) possibility: here, the original disc is split only into two rings, and 5 of the small discs are used to cover the inner (green) ring, the other 14 small discs are used to cover the outer (blue) ring. It is clear here that too much space is wasted in the outer ring (that ring was chosen too narrow), so this can not be an optimal solution.
| |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | When covering one ring with small discs, we ignore that there are parts of this ring covered already by the discs used for other rings. | ||||||||||||
- | The innermost "ring" will be a disc (i.e. the inner radius will be 0). | ||||||||||||
- | There may be just one "ring" in total (i.e. all smaller discs build a single regular polygon around the center). | ||||||||||||
- | Your return value must have an absolute or relative error less than 1e-9. | ||||||||||||
Constraints | |||||||||||||
- | discRadius is between 1.0 and 1000.0, inclusive. | ||||||||||||
- | numDiscs is between 1 and 2000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|