C. 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.

Sample test(s)
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<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
#define M 1000000007
__int64 n,m;
__int64 f(__int64 a, __int64 b)
{
if(a< || b<) return ;
return max((n/(a+))*(m/(b+)), (n/(b+))*(m/(a+)));
} int main()
{
__int64 k,ans=; scanf("%I64d%I64d%I64d",&n, &m, &k); if(k>n+m-) printf("-1\n");
else if(k==n+m-) printf("1\n");
else
{
ans=max(ans, f(, k));
ans=max(ans, f(m-, k-m+));
ans=max(ans, f(n-, k-n+));
printf("%I64d\n", ans);
} return ;
}

最新文章

  1. 切换npm源
  2. bootstrap 之 xs,sm,md,lg &amp;&amp; 主要颜色
  3. Mono登录界面记住密码的控件
  4. Makefile 开发环境全能管家
  5. 传奇的通迅协议与base64算法
  6. C++ Frequently asking question
  7. 第二百三十六天 how can I 坚持
  8. UVA 11396 Claw Decomposition(二分图)
  9. Java多线程(五) Lock接口,ReentranctLock,ReentrantReadWriteLock
  10. Castle Windsor Fluent Registration API
  11. asp.net+Sqlserver 通过存储过程读取数据
  12. google反向代理网址收集
  13. CloudStack API访问权限控制
  14. Azure上如何在Linux下挂载数据磁盘
  15. 组合,关联,聚合的区别(转自http://jimmyleeee.blog.163.com/blog/static/9309618200932014422932/)
  16. C# Note38: Export data into Excel
  17. NFine框架全选checkBox列错位
  18. lombok插件:Data自动get/set方法, Slf4j实现Logger的调用
  19. java多线程和Calendar(日历)常用API
  20. C语言中的控制语句: 判断、环循等;

热门文章

  1. flask基础之蓝图的使用(七)
  2. aarch64_n2
  3. nginx配置location总结及rewrite规则写法【转】
  4. Apache HBase Performance Tuning 官文总结
  5. Flask:文件配置方式实践及其中的各种问题记录
  6. Windows 10安装uWSGI:不可行、失败了
  7. 安装node版本管理工具之NVM
  8. No.3 selenium学习之路之鼠标&amp;键盘事件
  9. simple_tag
  10. 20155225 2016-2017-2《Java程序设计》课程总结