Jzzhu and Chocolate
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:

  • each cut should be straight (horizontal or vertical);
  • each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut);
  • each cut should go inside the whole chocolate bar, and all cuts must be distinct.

The picture below shows a possible way to cut a 5 × 6 chocolate for 5 times.

Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactly k cuts? The area of a chocolate piece is the number of unit squares in it.

Input

A single line contains three integers n, m, k (1 ≤ n, m ≤ 109; 1 ≤ k ≤ 2·109).

Output

Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

Examples
input
3 4 1
output
6
input
6 4 2
output
8
input
2 3 4
output
-1
Note

In the first sample, Jzzhu can cut the chocolate following the picture below:

In the second sample the optimal division looks like this:

In the third sample, it's impossible to cut a 2 × 3 chocolate 4 times.

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long n,m,k;
while(~scanf("%I64d%I64d%I64d",&n,&m,&k))
{
if(n>=k+||m>=k+)
{
long long maxx=max(n,m);
long long minn=min(n,m);
long long cl1=minn/(+k);
long long cl2=maxx/(+k);
//cout<<minn<<endl<<maxx<<endl<<cl1<<endl<<cl2<<endl;
long long tmpma=;
long long tmpmi=;
tmpmi=maxx*cl1;
tmpma=minn*cl2;
long long ans=max(tmpmi,tmpma);
if(ans>) printf("%I64d\n",ans);
//printf("%I64d\n",maxx/(k+1)*minn);
continue;
}
long long minn=min(n,m);
long long maxx=max(n,m);
long long cl1=k-minn+;
long long cl2=k-maxx+;
//cout<<minn<<endl<<maxx<<endl<<cl1<<endl<<cl2<<endl;
long long tmpma=;
long long tmpmi=;
if(cl1<maxx) tmpmi=maxx/(cl1+);
if(cl2<minn) tmpma=minn/(cl2+);
long long ans=max(tmpmi,tmpma);
if(ans>) printf("%I64d\n",ans);
else printf("-1\n");
}
return ;
}//

我感觉这道题是一种很巧妙的暴力,枚举可能的四种情况,取最大值。

最新文章

  1. zookeeper集群搭建
  2. 8种效果实例-jQuery anoSlide 焦点图轮播
  3. 转: CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法
  4. Duilib实现圆形头像控件
  5. C#获取指定日期为一年中的第几周
  6. 用NativeScript创建JavaScript原生移动应用
  7. 带约束优化问题 拉格朗日 对偶问题 KKT条件
  8. MSSQLServer基础03(数据检索(查询))
  9. App被拒绝的原因收录
  10. 【纯干货】SVN使用时应注意的那些事
  11. 一个页面从输入URL到页面加载显示完成的详细过程
  12. [置顶] Android图片异步加载之Android-Universal-Image-Loader
  13. 通信技术:SSE设计方案(一)--- 前端Server-Sent Events概念讲解和基础类库完善发布
  14. git的个人配置
  15. android 开发设计模式---Builder模式
  16. maven_常用命令
  17. javascript AOP(面向切面编程)
  18. Windows Azure Web Site (19) Azure Web App链接到VSTS
  19. C#实现字符串计算
  20. 洛咕P4542 [ZJOI2011]营救皮卡丘

热门文章

  1. go语言基础之普通函数的调用流程
  2. python with和上下文管理工具
  3. Git使用帮助
  4. Google Maps API v2密钥申请以及实现地图定位导航
  5. filter中的dispatcher解析
  6. ionic 调用手机的打电话功能
  7. webpack CommonsChunkPlugin 提取公共代码
  8. 百度地图总结第二篇--POI检索功能
  9. Appium(JAVA)Windows 7系统搭建及示例运行
  10. Swift 与 Object-C 交互 (Swift版本为:1.2)