QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#3923. 可可联盟

统计

Alice 和 Bob 决定分享一块巧克力,这是一块 $n \times m$ 的矩形巧克力网格。他们决定 Alice 应该得到 $a < n \cdot m$ 块,而 Bob 应该得到 $b = n \cdot m - a$ 块。为了分割巧克力,他们重复地取出一块巧克力并将其水平或垂直切开,从而产生两块更小的巧克力。参见图 C.1 中的示例。

Alice 和 Bob 需要进行的最少分割次数是多少,才能将这块 $n \times m$ 的巧克力分成总数分别为 $a$ 和 $b$ 的两堆巧克力?

图 C.1:样例输入 2 的解法示意图,展示了原始的 10x10 巧克力被分割了三次,形成了 10x2、10x5、3x3 和 7x3 大小的块。将 10x5 和 7x3 的块分给 Alice,她总共得到了 50 + 21 = 71 块巧克力。

输入格式

输入包含一行,包含三个整数 $n, m$ 和 $a$ ($1 \le n, m \le 10^6, 1 \le a < n \cdot m$)。

输出格式

输出实现所需巧克力分割所需的最少分割次数。

样例

样例输入 1

3 10 9

样例输出 1

1

样例输入 2

10 10 71

样例输出 2

3

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.