QOJ.ac

QOJ

حد الوقت: 1.5 s حد الذاكرة: 64 MB مجموع النقاط: 160

#16379. STANOVI

الإحصائيات

Stanko 在一家建筑公司担任建筑师。他当前的任务是为位于萨格勒布(Zagreb)的一栋住宅楼设计平面图。他必须确定一种用墙壁分割大楼楼层的方法,以建造矩形形状的公寓。每面建造的墙壁都必须与大楼的边界平行。

更具体地说,在平面图中,楼层被表示为一个大小为 $N \times M$ 的大矩形,其中每个公寓都是位于大矩形内部的大小为 $a \times b$ 的较小矩形。数 $a$ 和 $b$ 必须是整数。

此外,楼层必须完全被公寓覆盖——楼层中的每个点都必须位于某个公寓内。公寓之间不能重叠,但可以接触。

为了防止室内昏暗,公寓必须有窗户。因此,每个公寓都必须与代表楼层的大矩形的边界共享至少一条边,以便能够安装窗户。

此外,所有公寓的面积应尽可能接近 $K$。一个大小为 $a \times b$ 的公寓的面积偏差定义为 $(a \cdot b - K)^2$。平面图的总偏差是所有公寓偏差的总和。

Stanko 想要建造他所能建造的最佳建筑,即总偏差最小的建筑。请帮助他编写一个程序,以确定满足任务条件下的平面图的最小可能总偏差。

(a) 对应于第一个样例的有效公寓布局。 (b) 无效的公寓布局。公寓的边长不是整数,且存在一个没有窗户的公寓。

输入格式

输入仅包含一行,有三个整数 $N, M, K$ ($1 \le N, M \le 300, 1 \le K \le 10\,000$)。

输出格式

输出仅包含一行,表示公寓布局的最小可能总偏差。

样例

输入 1

3 3 2

输出 1

1

输入 2

2 2 2

输出 2

0

输入 3

2 3 4

输出 3

2

说明

样例 1 说明:该样例对应于题目描述中左侧的图像。请注意,无法达到总偏差为 0 的方案。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.