Chocolate Bar
시간 제한1초메모리 제한2048 MB
N x M 초콜릿을 잘라 넓이의 합이 정확히 K인 조각들을 얻을 때 최소 자르기 횟수를 구합니다.
문제
You have a bar of chocolate which can be represented as a rectangle. Originally, the chocolate bar has a width of and a height of . For this problem, denote as a chocolate bar with a width of and a height of .
You want to eat the chocolate with a total area of exactly . However, you always eat a chocolate bar as a whole; that is, if you eat a chocolate bar , then you will eat all the chocolate with area .
To be able to eat exactly total area, you are allowed to perform any of the following operations any number of times (possibly zero).
- Pick one bar of chocolate then split it into two bars: and such that is an integer that satisfies .
- Pick one bar of chocolate then split it into two bars: and such that is an integer that satisfies .
Determine the minimum number of operations such that it is possible to eat some chocolate bars with a total area of .
입력
Input consists of three integers (; ).
출력
Output a single integer representing the minimum number of operations such that it is possible to eat some chocolate bars with a total area of .