cf 450c Jzzhu and Chocolate
1 second
256 megabytes
standard input
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.
A single line contains three integers n, m, k (1 ≤ n, m ≤ 109; 1 ≤ k ≤ 2·109).
Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.
3 4 1
6
6 4 2
8
2 3 4
-1
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的更多相关文章
- codeforces 450C. Jzzhu and Chocolate 解题报告(449A)
题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得 ...
- Codeforces 450C:Jzzhu and Chocolate(贪心)
C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: st ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- CF 633 F. The Chocolate Spree 树形dp
题目链接 CF 633 F. The Chocolate Spree 题解 维护子数答案 子数直径 子数最远点 单子数最长直径 (最长的 最远点+一条链) 讨论转移 代码 #include<ve ...
- 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 ...
- Codeforces449A Jzzhu and Chocolate && 449B Jzzhu and Cities
CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀, ...
- Jzzhu and Chocolate
CF#257 div2 C:http://codeforces.com/contest/450/problem/C 题意:n*m的方格,每次可以横着或者纵向的切一刀,问切k之后,最小的最大是多少. 题 ...
- codeforces #257 C称号Jzzhu and Chocolate
职务地址:http://codeforces.com/contest/450/problem/C 这次CF的时候绝壁脑残了. ..A题和C题都出现了脑残失误... 唯一一个AC的B题还是被HACK了. ...
- CF 450E Jzzhu and Apples 数学+模拟
E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- mysql的正则表达式
所谓正在表达式,就是通过模式去匹配一类字符串.MySQL支持的模式字符如下表所示: MySQL支持的模式字符 模式字符 含义 ^ 匹配字符串的开始部分 $ 匹配字符串的结束部分 . 匹配字符串中的任意 ...
- IIs 中运行asp程序出现“An error occurred on the server when processing the URL. Please contact the system administrator.”错误
在个人的win08系统上使用IIs运行 asp程序结果出现了以下错误 An error occurred on the server when processing the URL. Please c ...
- 会说话的HTML--语义化杂谭-TGideas-腾讯游戏官方设计团队
家里有个熊孩子,经常会有一些意想不到的事情发生:回家的时候,他会笑呵呵冲过来,大声喊着“臭爸爸”:你让他把鞋穿上,他会提起鞋子往楼下扔...在小孩的世界里,他虽然会说话,但不一定明白其中的意思,不能正 ...
- Android媒体扫描详细解析之二(MediaScanner & MediaProvider)
上篇blog说到了经过对文件夹进行扫描如果后缀符合系统设定的一些格式,那么就会进行文件内容扫描下面我们紧接着STEP 14中的 status_t StagefrightMediaScanner::pr ...
- Nginx搭建flv mp4流媒体服务器[转]
Nginx搭建flv mp4流媒体服务器 作者:二蛋 时间:December 1, 2014 分类:Note 环境:Centos 6.4 32bit 一.安装依赖包 1.安装zlib wget htt ...
- js 函数节流throttle 函数去抖debounce
1.函数节流throttle 通俗解释: 假设你正在乘电梯上楼,当电梯门关闭之前发现有人也要乘电梯,礼貌起见,你会按下开门开关,然后等他进电梯: 但是,你是个没耐心的人,你最多只会等待电梯停留一分钟: ...
- VmProtect v2.12.3 安装注冊
执行vmprotect.exe開始安装: 1.选择语言.默觉得"English": 2.欢迎页,点"Next"到下一步: 3.授权信息,选"I acc ...
- no matching function for call to 'make_pair(std::string&, size_t&)'
rtl->push_back(make_pair<string, int>(str, pos)); 在redhat6上编译无问题,在centos7上编译出现错误: no matchi ...
- 一个字符串是否在另外一个字符串数组里 Array.Exists 的用法 Array.IndexOf 用法
转: using System; class Program { static void Main() { string[] array = { "cat", "dot& ...
- SQL数据库异地备份
服务器:windows sever 2008(简称为A) 数据库:SQL server 2008 R2(安装在A上) 普通台式机:windows 7(简称为B) 目的:将A中的数据定时自动备份到B中 ...