Universal Cup Judging System

Universal Cup

実行時間制限: 3.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓
統計

Hitagi Senjougahara has a piece of paper of height $h$ and width $w$. The list is divided into $1 \times 1$ cells. Let's assume that the bottom left corner of the paper has coordinates $(0, 0)$ and the top right corner has coordinates $(h, w)$.

Hitagi can make multiple cuts, each one being either vertical or horizontal. For horizontal cuts, Hitagi chooses integer height $h' \in [1, h - 1]$ and cuts all pieces of paper that cross the line. For vertical cuts, Hitagi chooses integer width $w' \in [1, w - 1]$ and cuts all pieces of paper that cross the line. So if she performs $c_h$ horizontal cuts at different heights and $c_w$ vertical cuts at different widths, she will end up with $(c_h + 1)(c_w + 1)$ pieces of paper.

Now Hitagi wonders what is the minimal number of cuts needed to make so all rectangular pieces of paper she ends up with have an area not exceeding $s$.

You are tasked to find the answer for $t$ tuples $h, w, s$.

Input

First line contains integer $t$ ($1 \le t \le 1\,000$) — number of tests you need to solve.

Next $t$ lines contain tuples of integers $h, w, s$ ($1 \le h, w, s \le 10^9$) — dimensions of the paper and wanted area.

Output

Output $t$ lines, each containing 1 integer — answer for the tuple.

Examples

Input 1

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

Output 1

2
3
0
1
55

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#366EditorialOpen题解jianglyView

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.