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)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路 ...
随机推荐
- Interger不可变原理
1.先看代码: package main.java.db.mq; public class TestSwap { public static void main(String[] args) { In ...
- python操作mysql(pymysql + sqlalchemy)
pymysql pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同. 下载安装 pip3 install pymysql 使用操作 1.执行sql #!/usr/bi ...
- 缓存数据库-redis数据类型和操作(hash)
一:Redis 哈希(Hash) Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象. Redis 中每个 hash 可以存储 232 - 1 ...
- python网络编程-socket样例
socket样例 一:只能一个客户端发送一个信息. 客户端 # -*- coding:utf-8 -*- __author__ = 'shisanjun' import socket sock=soc ...
- csslint在前端项目中的使用
大家都听说过jslint,eslint,不过你可能没见过csslint,你可能会问csslint有什么用,为什么今天要说csslint,是因为我在开发中遇到一个坑,其实之前不怎么使用csslint的, ...
- caffe+win7+vs2013 仅CPU环境安装
笔者对深度学习一直充满着好奇与兴趣,之前学校都是研究图像处理的特征点方式,机器学习使用也不多,别提深度学习了. 在看了李宏毅大佬的PPT后,有了初步的认识,虽然是渣渣电脑,也想自己跑几个深度模型. 说 ...
- maven pom.xml配置
<repositories> <repository> <id>central</id> <name>Maven Repository Sw ...
- Effective STL 学习笔记 Item 34: 了解哪些算法希望输入有序数据
Effective STL 学习笔记 Item 34: 了解哪些算法希望输入有序数据 */--> div.org-src-container { font-size: 85%; font-fam ...
- python对象学习
python对象的介绍 python使用对象模型来存储数据,构造任何类型的值都是一个对象,尽管python被当成面向对象的编程语言,但是完全编写不使用任何类和实例的脚本.所有的python对象都拥有三 ...
- 1、树莓派3B开箱+安装系统
说白了,树莓派就是英国人为学生开发的一款微型电脑.电脑能干什么,那就多了.英国小学生有用树莓派做气象站的,有检测家长开门回家的(可以安心玩游戏了),总之脑洞有多大就可以玩多大. 了解到了之后就一直心水 ...