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. osglightpoint例子 [转]

    该例子演示了光点的效果,主要应用osgSim库中的LightPoint.LightPointNode. SequenceGroup.BlinkSequence,osgSim库属于仿真库,扩展库.应用o ...

  2. java垃圾回收机制--可达性算法

    先说一些题外话,Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区,这些区分为线程私有区和线程共享区 1.线程私有区 a.程序计数器 记录正在执行的虚拟机字节码指令地址 ...

  3. tomcat(5)servlet容器

    [0]README 0.0)本文部分文字描写叙述转自:"深入剖析tomcat",旨在学习 tomcat(5)servlet容器 的基础知识. 0.1)intro to servle ...

  4. Linux下性能监控的三把军刀

    Linux主机怎么管,十八般兵器件件都可以算得上是瑞士军刀,称手的兵器一两件即可,最常用的,莫过于stat家族三兄弟吧. 计算机主要资源是什么?CPU.内存和磁盘?尽管现在云计算技术有多普及,查看一个 ...

  5. 跟踪数据库中执行时间超过1.5秒的语句及SP,导入数据库

    跟踪 --============================================================================ --新建两个目录 D:\InOut\ ...

  6. Unicode 与UTF-8 关系

    作者:邱昊宇链接:https://www.zhihu.com/question/23374078/answer/24385963来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  7. windows设置文件夹显示缩略图

      windows设置文件夹显示缩略图 CreateTime--2017年7月26日16:32:59Author:Marydon 为什么要显示缩略图? a.显示缩略图后,图片文件能够直接显示内容,不能 ...

  8. ibatis 批量插入

      ibatis 批量插入 CreationTime--2018年7月2日10点21分 Author:Marydon 1.说明 基于oracle的sql语句 2.主键id有默认值,比如:sys_gui ...

  9. 我的项目7 js 实现歌词同步(额,小小的效果)

    在项目中须要做一个播放器,还要实现歌词同步的效果,就跟如今搜狗音乐的歌词同步差点儿相同,在网上查了一些关于这方面的.整理了一下,在这里,其有用这种方法能够吗? <!DOCTYPE html> ...

  10. 40、JDBC相关概念介绍

    1.1.数据库驱动 这里的驱动的概念和平时听到的那种驱动的概念是一样的,比如平时购买的声卡,网卡直接插到计算机上面是不能用的,必须要安装相应的驱动程序之后才能够使用声卡和网卡,同样道理,我们安装好数据 ...