449A - Jzzhu and Chocolate 贪心
一道贪心题,尽量横着切或竖着切,实在不行在交叉切
#include<iostream>
#include<stdio.h>
using namespace std; int main(){
// freopen("in.txt","r",stdin);
long long n,m,k;
while(cin>>n>>m>>k){
if((n+m-2)<k){
printf("-1\n");
continue;
}
long long max=0,t;
if(n>m){
t=m;m=n;n=t;
}
long long ans;
if(m>=(k+1)){
ans=(n/(k+1)*m)>(m/(k+1)*n)?(n/(k+1)*m):(m/(k+1)*n);
}
else{
ans=(m/(k-(n-1)+1))>(n/(k-(m-1)+1))?(m/(k-(n-1)+1)):(n/(k-(m-1)+1)) ;
}
cout<<ans<<endl;
}
}
449A - Jzzhu and Chocolate 贪心的更多相关文章
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- 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. 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 解题报告(449A)
题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得 ...
- 【Codeforces 449A】Jzzhu and Chocolate
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 设最后行分成了x行,列分成了y列. 那么答案就是floor(n/x)floor(n/y) 然后x+y-2=k //即平均分配x行.y列 我们可 ...
- Codeforces 449C Jzzhu and Apples 贪心 (看题解)
Jzzhu and Apples 从大的质因子开始贪心, 如果有偶数个则直接组合, 如果是奇数个留下那个质数的两倍, 其余两两组合. #include<bits/stdc++.h> #de ...
- hdu 4112 Break the Chocolate 贪心
Break the Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...
- 【bzoj2430】[Poi2003]Chocolate 贪心
题目描述 有一块n*m的矩形巧克力,准备将它切成n*m块.巧克力上共有n-1条横线和m-1条竖线,你每次可以沿着其中的一条横线或竖线将巧克力切开,无论切割的长短,沿着每条横线切一次的代价依次为y1,y ...
随机推荐
- base64转码
Base64是一种编码方法,可以将任意字符转成可打印字符.使用这种编码方法,主要不是为了加密,而是为了不出现特殊字符,简化程序的处理. JavaScript原生提供两个Base64相关方法. btoa ...
- python学习之路-11 多线程、多进程、协程
python内置队列模块 queue queue的四种队列 q = queue.Queue() # 先进先出队列 q = queue.LifoQueue() # 后进先出队列 q = queue.Pr ...
- DOS 选择跳转实现、dos + bcp 双击导入和导出数据
DOS 选择跳转实现.dos + bcp 双击导入和导出数据 option.bat @echo off :Start2 cls goto Start :Start title Frequently U ...
- POJ-1118(超时,但未找到原因)
#include<iostream> #include<map> #include<vector> using namespace std; //y=kx+z ty ...
- C#中string.Empty和""、null的区别
string.Empty是string类的一个静态常量,而""则表示一个空字符串. string是一种特殊的引用类型,它的null值则表示没有分配内存. 使用ILSpy反编译Str ...
- AngularJs directive 'transclude' option 详解
transclude好像不是一个英语单词,有道词典里没有,百度翻译的意思是嵌入. transclude在angularjs的自定义的derective中是比较常见的一个东西,所有有必要要了解它. 我们 ...
- 我的开源框架之TAB控件
需求 (1)支持iframe.html.json格式的tab内容远程请求 (2)支持动态添加tab (3)支持远程加载完成监听,支持tab激活事件监听 (4)支持reload tab内容[如果是远程加 ...
- struts2注解驱动 零配置
一.配置web.xml<filter><filter-name>struts2</filter-name><filter-class>org.apach ...
- GIT 实验
服务器环境:linux + git + gitolite(gitolite是什么,说白了就是安装后建了一个仓库,管理员用户可以通过修改并上传配置文件实现GIT仓库及其权限的管理.提醒:别用那个gito ...
- shell之冒号的作用
冒号: :在shell中是一种命令,意思是总是为真,但是却不做任何操作,即总是为真的空命令 eg: [root@localhost ~]# ${abc:=t1}-bash: t1: comma ...