P29544 [洛谷] [COCI2014-2015#4] STANOVI
提高
题目描述

Problem Description

Stanko works as an architect at a construction company. His current task is to design a floor plan for a residential building in Zagreb. He must determine a method to partition the building floor into rectangular apartments using walls. Each wall must be parallel to the sides of the building. More precisely, the floor is represented in the plan as a large rectangle of dimensions $n \times m$, where each apartment is a smaller rectangle of dimensions $a \times b$ located inside the larger rectangle. The numbers $a$ and $b$ must be integers.

Additionally, the floor must be completely covered by the apartments—every point on the floor must be within an apartment. Apartments cannot intersect, but they can touch. To prevent darkness inside, each apartment must have a window. Therefore, each apartment must have an edge along the edge of the rectangle representing the floor, allowing for a window to be placed.

Furthermore, the area of all apartments $k$ must be approximately equal. The area deviation of an apartment of dimensions $a \times b$ is defined as $(a \times b - k)^2$. The deviation of the floor plan is the sum of the deviations of all apartments.

Stanko wants to build the best possible building, one with the smallest deviation. Help him by writing a program that determines the minimum possible deviation of a floor plan that meets the task conditions.

Input Format

A single line containing three integers $n, m, k$.

Output Format

A single line containing the minimum possible deviation of the apartment layout.

Sample Input and Output

Sample Input #1

3 3 2

Sample Output #1

1

Sample Input #2

2 2 2

Sample Output #2

0

Sample Input #3

2 3 4

Sample Output #3

2

Notes/Hints

Sample 1 Explanation

This sample corresponds to the left diagram in the problem description. Note that it is impossible to achieve a deviation value of $0$.

Data Size and Constraints

For $100\%$ of the data, $1 \le n, m \le 300$ and $1 \le k \le 10^4$.

Note

This problem is translated from COCI2014-2015 CONTEST #4 T6 STANOVI.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 2
样例输出
1