A lumberjack needs to transport a log to a paper mill. However, it's too long to fit in his truck, so he needs to cut it into multiple pieces. The log's length is L centimeters, and due to its nonuniform density, it can only be cut at certain places. The points at which it can be cut are represented by the expression
((A * i) mod (L - 1)) + 1, for all integers i between 1 and K, inclusive. Coordinates are measured as the distance in centimeters from the leftmost end of the log. The lumberjack is allowed to make at most C cuts.
Determine a strategy for cutting the log that minimizes the length of the longest resulting piece. The return value should be a String formatted as "MaxPart FirstCut" (quotes for clarity only), where MaxPart is the length of the longest piece and FirstCut is the coordinate of the leftmost cut. Both MaxPart and FirstCut must be integers with no leading zeroes. If there are multiple answers, return the one with the smallest FirstCut value.
|