본문 바로가기

problem solving/Problem Solving

Cake Cutting


Description

You are given a rectangular cake of integral dimensions w × h. Your goal is to divide this cake into m rectangular pieces of integral dimensions such that the area of the largest piece is minimal. Each cut must be a straight line parallel to one of the sides of the original cake and must divide a piece of cake into two new pieces of positive area. Note that since a cut divides only a single piece, exactly m − 1 cuts are needed.

If w = 4, h = 4, and m = 4, then the following cuts minimize the area of the largest piece:

However, if w = 4, h = 4, and m = 3, then the following cuts are optimal:

Input

The input test file will contain multiple test cases, each of which consists of three integers w, h, m separated by a single space, with 1 ≤ w, h, m ≤ 20 and mwh. The end-of-file is marked by a test case with w = h = m = 0 and should not be processed.

Output

For each test case, write a single line with a positive integer indicating the area of the largest piece.

Source

Stanford Local 2004


Solving

w x h 사이즈의 케익이 있다. 이 케익을 정확히 m-1번 잘라 m개의 조각으로 만들고 싶다. 케익 커팅은 x축과 y축에 평행하게만 자를 수 있고, 한 변의 길이는 반드시 단위길이의 정수배가 되어야 한다. 주어진 케익을 잘라 m개의 조각으로 만들었을 때 가장 큰 케익조각이 최소가 될 때 가장 큰 조각의 크기를 구하시오.

'problem solving > Problem Solving' 카테고리의 다른 글

Party at Hali-Bula  (0) 2008.10.12
Barbara Bennett's Wild Numbers  (0) 2008.10.12
Triangle  (0) 2008.10.09
Square  (0) 2008.10.07
Ubiquitous Religions  (0) 2008.10.07