QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#14428. Staple Stable

الإحصائيات

Hitagi Senjougahara 有一张高度为 $h$、宽度为 $w$ 的纸张。这张纸被划分为 $1 \times 1$ 的网格。 假设纸张的左下角坐标为 $(0, 0)$,右上角坐标为 $(h, w)$。

Hitagi 可以进行多次裁剪,每次裁剪可以是水平的或垂直的。对于水平裁剪,Hitagi 选择一个整数高度 $h' \in [1, h - 1]$,并切开所有穿过该水平线的纸张。对于垂直裁剪,Hitagi 选择一个整数宽度 $w' \in [1, w - 1]$,并切开所有穿过该垂直线的纸张。因此,如果她在不同的高度进行 $c_h$ 次水平裁剪,在不同的宽度进行 $c_w$ 次垂直裁剪,她最终将得到 $(c_h + 1)(c_w + 1)$ 张纸片。

现在 Hitagi 想知道,为了使最终得到的所有矩形纸片的面积都不超过 $s$,最少需要进行多少次裁剪。

你的任务是求出 $t$ 组三元组 $h, w, s$ 的答案。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 1\,000$) —— 需要解决的测试用例数量。

接下来的 $t$ 行,每行包含三个整数 $h, w, s$ ($1 \le h, w, s \le 10^9$) —— 纸张的尺寸和期望的最大面积。

输出格式

输出 $t$ 行,每行包含一个整数 —— 对应三元组的答案。

样例

输入样例 1

5
2 2 1
1 7 2
4 4 17
4 4 15
120 216 34

输出样例 1

2
3
0
1
55

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#366EditorialOpen题解jiangly2025-12-14 07:26:00View

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.