Codeforces Round #257 (Div. 2) C. 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<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
#define M 1000000007
__int64 n,m;
__int64 f(__int64 a, __int64 b)
{
if(a< || b<) return ;
return max((n/(a+))*(m/(b+)), (n/(b+))*(m/(a+)));
} int main()
{
__int64 k,ans=; scanf("%I64d%I64d%I64d",&n, &m, &k); if(k>n+m-) printf("-1\n");
else if(k==n+m-) printf("1\n");
else
{
ans=max(ans, f(, k));
ans=max(ans, f(m-, k-m+));
ans=max(ans, f(n-, k-n+));
printf("%I64d\n", ans);
} return ;
}
Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate的更多相关文章
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)
题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...
- Codeforces Round #257(Div. 2) B. Jzzhu and Sequences(矩阵高速幂)
题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 sec ...
- Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)
题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...
- Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...
- Codeforces Round #257 (Div. 2) B Jzzhu and Sequences
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, ple ...
- Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp
D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children
A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #257(Div.2) D Jzzhu and Cities --SPFA
题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路 ...
随机推荐
- numpy细碎知识点
np.random.rand() 基于python自带模块random的random函数的一个延伸吧,生成指定数量的列表 np.random.rand(a,b) 参数a,b均为整型,生成含有a个元素的 ...
- 64_t8
trytond-account-de-skr03-4.0.0-3.fc26.noarch.rpm 12-Feb-2017 13:06 53278 trytond-account-invoice-4.0 ...
- Sublime2编译Python程序EOFError:EOF when reading a line解决方法【转】
在Sublime2中编译运行Python文件时,如果代码中包含用户输入的函数时(eg. raw_input()),Ctrl+b编译运行之后会提示以下错误: 解决方法:安装SublimeREPL打开Su ...
- Oracle和MySQL的高可用方案对比【转】
关于Oracle和MySQL的高可用方案,其实一直想要总结了,就会分为几个系列来简单说说.通过这样的对比,会对两种数据库架构设计上的细节差异有一个基本的认识.Oracle有一套很成熟的解决方案.用我在 ...
- 【前端vue开发】vue项目使用sass less扩展语言所要安装的依赖
1.创建一个基于 webpack 模板的新项目 $ vue init webpack myvue 2.在当前目录下,安装依赖 $ cd myvue $ npm install 3.安装sass的依赖包 ...
- 使用gradle编译安卓APK
一.安装JDK 在安装Gradle之前需要先安装JDK,由于安装的是Gradle是4.4所以需要安装JDK1.8. 之前编译总是提示如下错误就是由于先安装的jdk1.7然后安装的1.8造成的,在Gra ...
- Luogu P3384 【【模板】树链剖分】
转载请注明出处,部分内容引自banananana大神的博客 ~~别说你不知道什么是树~~╮(─▽─)╭(帮你百度一下) 先来回顾两个问题:1,将树从x到y结点最短路径上所有节点的值都加上z 这也是个模 ...
- sql查询与修改数据库逻辑文件名,移动数据库存储路径
USE mydb GO --1.查询当前数据库的逻辑文件名 ) ) AS 'File Name 2'; --或通过以下语句查询: --SELECT name FROM sys.database_fil ...
- Python学习笔记:lambda表达式
lambda表达式:通常是在需要一个函数,但又不想去命名一个函数的时候使用,即匿名函数. 示例如下: add = lambda x,y : x+ y add(1,2) # 结果为3 1.应用在函数式编 ...
- Struts 2 Tutorial Basic MVC Architecture
Model View Controller or MVC as it is popularly called, is a software design pattern for developing ...