Jzzhu and Chocolate
CF#257 div2 C:http://codeforces.com/contest/450/problem/C
题意:n*m的方格,每次可以横着或者纵向的切一刀,问切k之后,最小的最大是多少。
题解:比赛的时候没有想到怎么处理,看了别人的题解,才恍然大悟。有一定的数学知识。最终块的大小平均来算是n(k1+1)*m/(k2+1),k1,k2分别表示横向切和纵向切的刀数,由于k1+k2==k,所以,要使得上述值最大,必须是(k1+1)*(k2+1)最小,就是让k1和k2 的差值越大即可。所以,我们总是把其中一维切完再切第二维。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long n,m,k,ans;
int main(){
while(~scanf("%I64d%I64d%I64d",&n,&m,&k)){
if(n+m-<k)ans=-;
else if(n+m-==k)ans=;
else {
if(n->=k)ans=m*(n/(k+));
else if(n-<k)ans=m/(k-n+);
if(m-<k)ans=max(ans,n/(k-m+));
else ans=max(ans,n*(m/(k+)));
}
printf("%I64d\n",ans);
}
}
Jzzhu and Chocolate的更多相关文章
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- 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 ...
- cf 450c Jzzhu and Chocolate
Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces 450C:Jzzhu and Chocolate(贪心)
C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: st ...
- codeforces 450C. Jzzhu and Chocolate 解题报告(449A)
题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得 ...
- Codeforces449A Jzzhu and Chocolate && 449B Jzzhu and Cities
CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀, ...
- codeforces C. Jzzhu and Chocolate
http://codeforces.com/contest/450/problem/C 题意:一个n×m的矩形,然后可以通过横着切竖着切,求切完k次之后最小矩形面积的最大值. 思路:设k1为横着切的次 ...
- 449A - Jzzhu and Chocolate 贪心
一道贪心题,尽量横着切或竖着切,实在不行在交叉切 #include<iostream> #include<stdio.h> using namespace std; int m ...
- Codeforces 450 C. Jzzhu and Chocolate
//area=(n*m)/ ((x+1)*(k-x+1)) //1: x==0; //2: x=n-1 //3: x=m-1 # include <stdio.h> long long m ...
随机推荐
- BDD框架之lettuce---python3.+安装报错
跟虫师学习python,学到BDD框架之lettuce( http://www.cnblogs.com/fnng/p/3415609.html),发现python3.5环境下安装lettuce后无法正 ...
- ckfinder 1
网上的破解教程对于2.4版本来说已经过时了. 以下是CKFinder 2.4 ASP.NET的亲测可用破解方法,经测试,只需修改两处代码. 打开ckfinder.js, 步骤1. 搜索替换如下代码: ...
- 安装 Panda3D 并使用原有的Python
Part 1:什么是Panda3D [原始网站] [中文版本] Part 2:注意事项 Panda3D的版本必须与Python相匹配 Part 3:使用已安装的Python 将‘C:\Panda3D- ...
- Git客户端(Windows系统)的使用
本文环境: 操作系统:Windows XP SP3 Git客户端:TortoiseGit-1.8.5.0-32bit 一.安装Git客户端 全部安装均采用默认! 1. 安装支撑软件 msysgit: ...
- 工作于内存和文件之间的页缓存, Page Cache, the Affair Between Memory and Files
原文作者:Gustavo Duarte 原文地址:http://duartes.org/gustavo/blog/post/what-your-computer-does-while-you-wait ...
- Percona Live 2016 PPT整理-zhaiwx_yinfeng
https://yq.aliyun.com/articles/54454?spm=5176.100239.bloglist.32.CllwIr
- STL——临时对象的产生与运用
所谓临时对象,就是一种无名对象.它的出现如果不在程序员的预期之下(例如任何pass by value操作都会引发copy操作,于是形成一个临时对象),往往造成效率上的负担.但有时候刻意制造一些临时对象 ...
- getopt 分析命令行参数 -n -t 1
在Linux中,我们常常用到 ls -l 等等之类带有选项项的命令,下面,让我们用C++来实现该类似的命令. 在实现之前,首先,我们来介绍一下一个重要函数:getopt() 表头文件 #include ...
- python 全栈开发之路 day1
python 全栈开发之路 day1 本节内容 计算机发展介绍 计算机硬件组成 计算机基本原理 计算机 计算机(computer)俗称电脑,是一种用于高速计算的电子计算机器,可以进行数值计算,又可 ...
- group by、order by 先后顺序问题
今天遇到个小问题 本来是很基础的问题 应该说 基础知道掌握的不牢 好了不说 错误 语句 : select a.a1 from table a where order by a.a1 gro ...