Stormwind

Problem Description

  *"So, people of Stormwind! Let us unite this day. Let us renew our promise to uphold and protect the Light, and together we will face down this dark new storm and stand firm against it—as humanity always has… and humanity always will!"*

  *The crowd saved its greatest roars for the end. A chorus of "Long live King Varian! Long live King Varian!" rose into the sky with vigor and conviction. The cheers were unending, echoing deep into Elwynn Forest and faintly reaching even the distant peaks of the Redridge Mountains.*

Varian Wrynn gained a rectangular piece of gold in the battle, with length n and width m. Now he wants to draw some lines on the gold, so that later he can cut the gold along the lines.

The lines he draws should satisfy the following requirements:

1. The endpoints of the lines should be on the boundary of the gold.
2. The lines should be parallel to at least one boundary of the gold.
3. After cutting along all the lines, each piece of gold is a rectangle with integer length and width.
4. After cutting along all the lines, the area of each piece of gold should be at least k.
5. Two lines should not share more than one common points.

Varian Wrynn wants to cut the gold in such a way that maximizes the lines he draws.

As Alliance's Supreme King, he certainly doesn't have time to do this. So he finds you! Please help him to cut the gold!

Input

The input consists of multiple test cases.

The first line contains an integer T (1≤T≤100) indicating the number of test cases.

Each test case consists of one line containing three integers n,m,k (1≤n,m,k≤105). Its guaranteed that n×m≥k.

Output

For each test case, output one line containing one integer, the maximum number of lines you can draw.

Sample Input

2
5 4 2
10 9 13

Sample Output

5
4

Hint

In the first test case, Varian Wrynn can draw 4 lines parallel to the boundary of length 4 and 1 line parrallel to the boundary of length 5. After cutting along the lines, he can get 10 pieces of gold of size 2.

题解:纯暴力,纯暴力,真的没想到这么简单,以此记录下自己愚蠢的那一刻。刚开始就找因子,没考虑到质数,WA了。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
ll ans;
int main()
{
	int _;
	cin>>_;
	while(_--)
	{
		ans=0;
		cin>>n>>m>>k;
		for(int i=1;i<=n;i++)
		{
			ll j=k/i;
			if(k%i)
				j++;
			if(j>m)
				continue;
			ans=max(ans,n/i+m/j-2);
		}
		cout<<ans<<endl;
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TherAndI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值