当前位置: 首页 > news >正文

CodeForces - 450C Jzzhu and Chocolate 数学 贪心

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.

Input

A single line contains three integers n, m, k (1 ≤ n, m ≤ 109; 1 ≤ k ≤ 2·109).

Output

Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

Examples

Input

3 4 1

Output

6

Input

6 4 2

Output

8

Input

2 3 4

Output

-1

Note

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.

题意:n*m的矩形,切k刀后,求最小块数最大是多少。

题解: 设 n那条边切x刀(x<=n-1) , m那条边切y刀(y<=m-1),我们得到的最小块最大为 n / (x+1) * m / (y + 1)

因为n ,m, x+y=k,是固定的,我们让(x + 1)*(y + 1)最小即可,所以让x或y最小即可

#include <iostream>
#include <cstdio>
#include <cstring> 
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define PI acos(-1)
const int N = 1e5+10;
const int mod=1e9+7;
int n,m,k;
int main() {while(~scanf("%d%d%d",&n,&m,&k)){if(n-1+m-1<k) cout<<"-1\n";else{ll ans=0;k++;if(n>=k) ans=max(ans,(ll)(n)/k*m);else ans=max(ans,(ll)(m)/(k-n+1));if(m>=k) ans=max(ans,(ll)(m)/k*n);else ans=max(ans,(ll)(n)/(k-m+1));cout<<ans<<endl;}}return 0;
}

 

相关文章:

flex blaze+java通信的例子

步骤&#xff1a; 1&#xff1a;建立java web程序 2&#xff1a; 下载blazeDS包&#xff0c;解压后将WEB-INF下的 flex&#xff0c;lib&#xff0c;web.xml复制到java程序的WEB-INF下 3&#xff1a;打开web.xml文件将以下代码的注释去掉&#xff0c;并修改 <param-value>…...

actionScript 数组去重

public function unique(array:Array):Array { for (var i:int0; i < array.length; i) { for (var j:inti 1; j < array.length; j) { //注意 if (array[i] array[j]) { array.splice(j, 1); j--; } } } return array…...

CodeForces - 545E Paths and Trees 最短路建树

题目链接&#xff1a;点击查看 Little girl Susie accidentally found her elder brothers notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted to know its solution and decided to a…...

ADB学习笔记

简介&#xff1a; ADB的全称为Android Debug Bridge&#xff08;调试桥&#xff09;&#xff0c; 它是一个客户端-服务器端程序&#xff0c;其中客户端是你用来操作的电脑, 服务器端是android设备。作用显而易见&#xff0c;能方便我们在PC上对手机进行调试的一些工作。 原理…...

http load介绍

前几天工作中要对项目的接口做简单压测&#xff0c;就使用了http load做了简单测试&#xff0c;下面介绍一下这款工具的使用说明。简介&#xff1a;http_load是基于linux平台的性能测试工具&#xff0c;它体积非常小&#xff0c;仅100KB。它以并行复用的方式运行&#xff0c;可…...

TestNG使用总结

TestNG简介&#xff1a; TestNG是一个测试框架&#xff0c;其灵感来自JUnit和NUnit&#xff0c;但同时引入了一些新的功能&#xff0c;使其功能更强大&#xff0c;使用更方便。 TestNG相较于Junit的优点&#xff1a; 可指定执行顺序&#xff0c; dependsOnMethods 属性来应对…...

面向对象编程的弊端

英文原文&#xff1a;What’s Wrong with OOP and FP 我不理解为什么人们会对面向对象编程和函数式编程做无休无止的争论。就好象这类问题已经超越了人类智力极限&#xff0c;所以你可以几个世纪的这样讨论下去。经过这些年对编程语言的研究&#xff0c;我已经清楚的看到了问题…...

flex 计算指定日期是本年度第几周

/** * 计算指定日期是本年度第几周 *传日年月日&#xff0c;返回number */ private function weekOfYear(yyyy:Number,mm:Number,dd:Number):Number{ var myDate:Date new Date(yyyy, mm - 1, dd); var startDate:Date new Date(yyyy,0,1); v…...

webservice学习记录笔记(一)

一、先理解什么是服务 现在的应用程序变得越来越复杂&#xff0c;甚至只靠单一的应用程序无法完成全部的工作。更别说只使用一种语言了。 写应用程序查询数据库时&#xff0c;并没有考虑过为什么可以将查询结果返回给上层的应用程序&#xff0c;甚至认为&#xff0c;这就是数…...

接口测试那些事儿

什么是接口&#xff1f; 首先&#xff0c;在讲接口测试之前&#xff0c;我们先要搞清楚接口类型的概念。 接口&#xff1a;可能是系统与系统&#xff08;包括服务与服务&#xff09;之间的调用&#xff0c;像A系统&#xff08;服务&#xff09;给B系统&#xff08;服务&#x…...

CodeForces - 1084C The Fair Nut and String 思维

The Fair Nut found a string s. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences p1,p2,…,pk , such that: For each i (1≤i≤k), spi a.For each i(1≤i<k), there is…...

Gym - 101986B Parallel Lines dfs暴力

链接&#xff1a;点击查看 题意&#xff1a;偶数个点&#xff0c;两点可连成一条线&#xff0c;求平行线最大对数 题解&#xff1a;当时想的时候傻逼了&#xff0c;想成了每次选两个点就是16*15/2 * 14*13/2 ..... 其实不需要这样&#xff0c;因为每个点必须要匹配一个的&…...

POJ - 2406 Power Strings next数组应用循环节

题目链接&#xff1a;点击查看 Language:Default Power Strings Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 61784 Accepted: 25534Description Given two strings a and b we define a*b to be their concatenation. For example, if a "abc" and…...

CodeForces - 545D Queue 贪心 排序

题目链接&#xff1a;点击查看 Little girl Susie went shopping with her mom and she wondered how to improve service quality. There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he …...

Jmeter访问HTTPS请求

公司最近在搞全站HTTPS改造&#xff0c;进一步提高网站的安全性&#xff0c;防止运营商劫持。那么&#xff0c;改造完成后&#xff0c;所有前后端的URL将全部为https。 So &#xff0c;研究下怎么用Jmeter访问https请求呢。 其实很简单&#xff0c; 第一步在jmeter中创建HTT…...

JSON相关知识点

JSON是工作中经常会遇到的一种数据结构&#xff0c;下面来讲讲与他相关的一些知识点。 JSON简介&#xff1a; JSON: JavaScript Object Notation(JavaScript 对象表示法) JSON 是存储和交换文本信息的语法,类似 XML。 JSON 比 XML 更小、更快&#xff0c;更易解析。 JSONObj…...

牛客网 Applese 走方格

题目链接&#xff1a;点击查看 题解&#xff1a;我们容易发现到当n,m都为奇数时&#xff0c;是回不到原点的&#xff0c;因为你无论哪个方向走一去一回就是两步&#xff0c;所以n和m必然有一个偶数&#xff0c;那至于我们怎么走呢&#xff0c;看下图&#xff0c;注意的是n1,m2…...

mysql重置Root密码

方法一: 在my.ini的[mysqld]字段加入&#xff1a; skip-grant-tables 重启mysql服务&#xff0c;这时的mysql不需要密码即可登录数据库 然后进入mysql mysql>use mysql; mysql>更新 user set passwordpassword(新密码) WHERE Userroot; mysql>flush privileges; 运…...

idea常用技巧收集

idea相比eclipse的优点我在这里就不赘述了&#xff0c;更多参考&#xff1a;idea官网,本文重点讲下自己在idea使用过程中常用的一些技巧&#xff0c;以后随时更新…… 主要分成三大块&#xff1a; 1. 系统设置 2. 快捷键 3. 其他设置 系统设置 主题风格设置&#xff1a;默…...

初识spring RestTemplate

《spring实战》读书笔记之初识spring RestTemplate。首先需要先了解下什么是REST。 REST&#xff1a;官方解释&#xff0c;表述性状态转移。 感觉还是不知所云&#xff0c;参考下怎样用通俗的语言解释REST&#xff0c;以及RESTful&#xff1f; 即URL定位资源&#xff0c;用H…...

ZOJ - 2968 Difference Game 思维

题目链接&#xff1a;点击查看 Now you are going to play an interesting game. In this game, you are given two groups of distinct integers and C coins. The two groups, named Ga and Gbrespectively, are not empty and contain the same number of integers at firs…...

单元测试框架-Junit介绍

在工作中编写接口脚本中经常用到junit作为测试框架&#xff0c;下面总结一下junit的用法和编写规范&#xff0c;供大家参考。 junit简介&#xff1a; 基于Java语言的单元测试框架&#xff0c;在日常工作中被广泛运用于单元测试和接口测试。 junit官网&#xff1a;http://jun…...

javaSE之动态代理

动态代理技术&#xff1a; 使程序更加灵活&#xff0c;可以在代理java类的时候加入一些功能。 很类似过滤器&#xff0c;区别&#xff1a; 过滤器是自己编写西横须实现的功能 动态代理是JVM内部机制 实现步骤&#xff1a; 1.真是业务对象&#xff08;被代理对象&#xff09; 2…...

CodeForces - 500B New Year Permutation floyd+选择排序

User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible. Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1…...

Hibernate 主键生成策略

<generator>:主键生成策略 increment:递增,hibernate自动产生主键.max(id) ,采用带走1算法,多进程/集群环境下不推荐使用. identity:设置表主键是自增字段,映射文件采用该策略,依赖底层库, auto_increment identity 适用于MySQL、DB2、MS SQL Server&#xff0c;…...

flex 事件机制详解

事件机制的工作流程 1&#xff1a;关于事件流 当一个事件发生&#xff0c;必然存在一个派发事件的对象&#xff0c;这里称之为目标对象。 当事件发生后flashPlayer生成一个携带数据的对象&#xff0c;然后检查目标对象是否处于显示层中&#xff0c;如果是则遍历从根容器一直到目…...

codeforces 501 C. Misha and Forest 巧妙的拓扑排序

Lets define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first inte…...

HDU - 3746 Cyclic Nacklace next数组求 循环节

题目链接&#xff1a;点击查看 CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about how to tide over the last days. …...

CodeForces - 557C Arthur and Table 预处理 前缀

题目链接&#xff1a;点击查看 题意&#xff1a;有n个桌腿&#xff0c;要砍掉某些桌腿&#xff0c;使剩下的桌腿中长度最大的桌腿的数量如果超过一半。砍掉每个桌腿需要付出代价。求最小的代价和&#xff0c;操蛋&#xff0c;砍掉的意思是直接去掉&#xff0c;我理解成了&…...

MD5加密算法详解

注&#xff1a;MD5不是绝对的安全&#xff0c;有俩md5解决 /******************************************************************************* * keyBean 类实现了RSA Data Security, Inc.在提交给IETF 的RFC1321中的keyBean message-digest * 算法。 *****************…...

每天一个adb命令:screen 命令详解

screen命令分为截屏screencap命令及录制视频screenrecord命令。 screencap命令&#xff1a; sage: screencap [-hp] [-d display-id] [FILENAME]-h: this message-p: save the file as a png.-d: specify the display id to capture, default 0. If FILENAME ends with .png …...

markdown编写入门

什么是markdown&#xff1f; Markdown 是一种轻量级的「标记语言」&#xff0c;通过简单的标记符号来格式化排版&#xff0c;是文本展现的更加优美&#xff0c;形象。 markdown优点&#xff1a; 1.不像office&#xff0c;存在版本兼容问题&#xff0c;markdown无此问题&#…...

CCPC-Wannafly Winter Camp Day5 (Div2, onsite)

题目链接&#xff1a;点击查看 Kropki&#xff1a; 题目描述&#xff1a; 你有一个11到nn的排列p_1, p_2, \dots, p_np1​,p2​,…,pn​&#xff0c;对于所有的i (1\leq i\leq n-1)i(1≤i≤n−1)&#xff0c;如果p_ipi​和p_{i1}pi1​中&#xff0c;有一个数是另一个的两倍&…...

《Maven实战》读书笔记

之前对Maven有些认识&#xff0c;通过这本书《Maven实战》一起系统的回顾一下&#xff0c;总结的东西不会很全面&#xff0c;但都是日常工作中最常用的。 简介&#xff1a; maven翻译为“知识的积累”&#xff0c;基于项目对象模型&#xff08;Project Object Model&#xff0…...

记一次爬虫实践(一):思路及模拟登录

需求背景 因为我们的应用通常运行在h5上&#xff0c;因此图片格式选择了加载较快的webp格式&#xff0c;但是运营提起有在pc上批量下载图片&#xff08;要求图片格式&#xff09;的需求&#xff0c;目前比较麻烦&#xff0c;需要登录h5-找到接口中对应图片资源-一张张另存为到…...

SSH免密码登录

公司服务器很多的话&#xff0c;如果每次连接都需要输入密码&#xff0c;那就太麻烦了。So&#xff0c;免密登录就可以大大提高我们的工作效率了。 下面介绍ssh免密登录的方法&#xff1a; 实现步骤&#xff1a; 1.在你的自己的机器下面使用ssh-keygen命令来实现创建公钥 使…...

log4j学习demo

log4j简介 Log4j是Apache的一个开放源代码项目&#xff0c;是项目中比较常用的日志记录组件。 引入log4j <dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.14</version></dependency> log4…...

flex验证座机,手机的框架

import mx.utils.StringUtil; import mx.validators.ValidationResult; import mx.validators.Validator; public class PhoneValidator extends Validator { public function PhoneValidator() { super(); } private var _phoneInvalid:String"正确格式(010-865…...

CodeForces - 555C Case of Chocolate set pair

题目链接&#xff1a;点击查看 题意&#xff1a;有一个n*n的矩形&#xff0c;给你对角线上的坐标&#xff0c;给你一个方向&#xff0c;问能走几个坐标&#xff0c;遇到之前已经经过的坐标就停止 题解&#xff1a;当给你一个坐标(x,y)&#xff0c;方向向上时&#xff0c;他能…...

HDU - 2328 Corporate Identity / POJ - 3080 Blue Jeans kmp 枚举

题目连接&#xff1a;点击查看 题意&#xff1a;n个字符串最长公共子串&#xff0c;相同长度就找字典序小的&#xff0c;poj那个是长度小于3&#xff0c;输出那句话 题解&#xff1a;以某一字符串为基准&#xff0c;枚举每个子串&#xff0c;然后暴力kmp即可&#xff0c;特记…...

HDU - 4389 X mod f(x) 数位dp

题目链接&#xff1a;点击查看Here is a function f(x):int f ( int x ) {if ( x 0 ) return 0;return f ( x / 10 ) x % 10;}Now, you want to know, in a given interval [A, B] (1 < A < B < 10 9), how many integer x that mod f(x) equal to 0. Input The fi…...

spring装配bean

最近在看《spring实战》一书&#xff0c;记录下spring装配bean这一章中自己学到的一些知识点。下面简单说明下bean和装配这两个概念的意思。 bean&#xff1a;在spring中代表组件&#xff0c;通过bean将不同的组件联系在一起。装配&#xff1a;是指创建应用对象之间协作关系的行…...

CodeForces - 500D New Year Santa Network 树形dp 记忆化 求期望

New Year is coming in Tree World! In this world, as the name implies, there are ncities connected by n - 1 roads, and for any two distinct cities there always exists a path between them. The cities are numbered by integers from 1 to n, and the roads are …...

POJ - 1451 T9 字典树

题目连接&#xff1a;点击查看 Background A while ago it was quite cumbersome to create a message for the Short Message Service (SMS) on a mobile phone. This was because you only have nine keys and the alphabet has more than nine letters, so most character…...

CodeForces - 545C Woodcutters dp

题目链接&#xff1a;点击查看 Little Susie listens to fairy tales before bed every day. Todays fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below…...

每天一个adb命令:am 命令详解

am 这个命令可以帮助我们直接启动activity、service及广播。 adb shell am 可以查看命令的详细说明。 usage: am [subcommand] [options] usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>][--sampling INTERVAL] [-R COUNT] [-S] [--opengl-tra…...

常用HTML标签简介

HTML&#xff1a;超文本标记语言 这个没啥技术含量&#xff0c;这里只是简单介绍&#xff0c;主要是要熟能生巧。 布局相关&#xff1a; <!-- 标记导航 --><nav></nav> <!-- 标记侧边栏 --><aside></aside> <!-- 标记正文 --><…...

Appium学习遇到的坑

安装篇 Q1&#xff1a;安装时要求java运行环境为最低1.8&#xff0c;我原先的jdk1.7无法运行。 A1&#xff1a;升级jdk后解决。附appium安装教程 配置篇 Q2&#xff1a;运行提示error&#xff1a;Error: Android bootstrap socket crashed: Error: getaddrinfo ENOTFOUND lo…...

Python高级特性

Python高级特性 切片迭代及迭代器列表生成式生成器 这些高级特性的作用都是一样的&#xff0c;为了代码的简洁、高效运行。 切片 切片让取一个list或tuple的部分元素变得相当简单&#xff0c; e.g: L[‘jack’,’mike’,’jerry’] 那么第一个位置&#xff0c;索引为0&a…...

Manacher 马拉车算法 吉哥系列故事——完美队形II HDU - 4513

吉哥又想出了一个新的完美队形游戏&#xff01;   假设有n个人按顺序站在他的面前&#xff0c;他们的身高分别是h[1], h[2] ... h[n]&#xff0c;吉哥希望从中挑出一些人&#xff0c;让这些人形成一个新的队形&#xff0c;新的队形若满足以下三点要求&#xff0c;则就是新的…...