#2481

Minimum Cuts to Divide a Circle

pupil · 420 · lc easy +25 · verified · 56.1% accepted · 321 likes · top 50%

Description

A valid cut on a circle is either a chord passing through the center (touching two edge points) or a radius (touching one edge point and the center). Given integer n, return the fewest valid cuts needed to divide the circle into n equal slices.

Example 1:

Input: n = 4
Output: 2
Explanation:
The above figure shows how cutting the circle twice through the middle divides it into 4 equal slices.

Example 2:

Input: n = 3
Output: 3
Explanation:
At least 3 cuts are needed to divide the circle into 3 equal slices.
It can be shown that less than 3 cuts cannot result in 3 slices of equal size and shape.
Also note that the first cut will not divide the circle into distinct parts.

Code

1
2
3