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 ;
}//

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

cf 450c Jzzhu and Chocolate的更多相关文章

  1. codeforces 450C. Jzzhu and Chocolate 解题报告(449A)

    题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得 ...

  2. Codeforces 450C:Jzzhu and Chocolate(贪心)

    C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: st ...

  3. Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)

    主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...

  4. CF 633 F. The Chocolate Spree 树形dp

    题目链接 CF 633 F. The Chocolate Spree 题解 维护子数答案 子数直径 子数最远点 单子数最长直径 (最长的 最远点+一条链) 讨论转移 代码 #include<ve ...

  5. Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate

    C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces449A Jzzhu and Chocolate && 449B Jzzhu and Cities

    CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀, ...

  7. Jzzhu and Chocolate

    CF#257 div2 C:http://codeforces.com/contest/450/problem/C 题意:n*m的方格,每次可以横着或者纵向的切一刀,问切k之后,最小的最大是多少. 题 ...

  8. codeforces #257 C称号Jzzhu and Chocolate

    职务地址:http://codeforces.com/contest/450/problem/C 这次CF的时候绝壁脑残了. ..A题和C题都出现了脑残失误... 唯一一个AC的B题还是被HACK了. ...

  9. CF 450E Jzzhu and Apples 数学+模拟

    E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. GPGPU OpenCL使用结构体数据

    OpenCL编程中可以使用结构体,只需要在核函数kernel中提供同样的结构体申明就可以啦. 如果在主函数中定义了结构体: typedef struct studentNode{ int age; f ...

  2. uva 10994 - Simple Addition(规律)

    题目链接:uva 10994 - Simple Addition 题目大意:给出l和r,求∑(l≤i≤r)F(i), F(i)函数题目中有. 解题思路:由两边向中间缩进,然后l和r之间的数可以按照1~ ...

  3. ExtJS ComboBox 录入智能提示

    ExtJS ComboBox非常复杂,有很多的属性:其中有的属性是针对某一种特定的方案而设计的,不是所有情况下都有效.我想下拉选择能支持录入,并且录入时能智能提示,弄了半天可以了,但是只能是mode= ...

  4. 原生对话框【Dialog】AlertDialog和.Builder

    使用大全 public class MainActivity extends ListActivity );                     pd.setProgress(i);//改变当前进 ...

  5. IOS UITableView删除功能

    UITbableView作为列表展示信息,除了展示的功能,有时还会用到删除,比如购物车等.删除功能可以直接使用系统自带的删除功能,当横向轻扫cell时,右侧出现红色的删除按钮,点击删除当前cell. ...

  6. excel 快捷使用

    1)excel填充相同内容 A:在需要填充相同内容的格中一个添加需要的内容,然后选中所有填充格,快捷键 ctrl-D 2)excel中合并单元格快捷键 A:1.点击上方-其他命令 2.选择“合并”进行 ...

  7. Android选择/拍照 剪裁 base64/16进制/byte上传图片+PHP接收图片

    转载请注明出处:http://blog.csdn.net/iwanghang/article/details/65633129认为博文实用,请点赞,请评论,请关注.谢谢! ~ 老规矩,先上GIF动态图 ...

  8. VC中关于预编译头文件的概括,以及无法打开预编译头文件的错误解决

    1.预编译头文件 在VC中编译器一般都是以文件为单位进行编译,如果修改了工程中的一个文件,那么将导致所有文件都要从新编译,这样的编译将耗费很长时间.为了提高编译速度,将那些不常被修改,比较稳定,文件单 ...

  9. iOS 检查app版本更新操作

    iOS 检查app版本更新操作 1:获取本地安装的版本信息: [NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle ...

  10. 安装TeX及中文支持

    2014.7.19更新: 以下的笔记适用于在基于Ubuntu的发行版(比方LinuxMint)安装Texlive2013.2014: 第一步依据本机状况.可能不须要. Texlive2014已经能够下 ...