Chocolate Bar
Time limit1sMemory limit2048 MB
Given an N by M chocolate bar and a target area K, find the fewest splits needed so that some pieces total exactly K.
- Level
Medium5 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
You have a chocolate bar shaped like a rectangle. Originally, the bar has width and height . In this problem, denotes a chocolate bar with width and height .
You want to eat chocolate with a total area of exactly . However, you always eat a bar as a whole. If you eat a bar , you eat all of its area .
You may perform any of the following operations any number of times, including zero.
- Pick one bar and split it into two bars and , where is an integer with .
- Pick one bar and split it into two bars and , where is an integer with .
Find the minimum number of operations needed so that you can eat some bars with a total area of exactly .
Input
Three integers , , and are given (, ).
Output
Print a single integer, the minimum number of operations needed so that some bars can be eaten with a total area of exactly .