博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate
阅读量:6612 次
发布时间:2019-06-24

本文共 2310 字,大约阅读时间需要 7 分钟。

C. Jzzhu and Chocolate
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.

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.

Sample test(s)
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.

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 #define M 100000000716 __int64 n,m;17 __int64 f(__int64 a, __int64 b)18 {19 if(a<0 || b<0) return 0;20 return max((n/(a+1))*(m/(b+1)), (n/(b+1))*(m/(a+1)));21 }22 23 int main()24 {25 __int64 k,ans=0;26 27 scanf("%I64d%I64d%I64d",&n, &m, &k);28 29 if(k>n+m-2) printf("-1\n");30 else if(k==n+m-2) printf("1\n");31 else32 {33 ans=max(ans, f(0, k));34 ans=max(ans, f(m-1, k-m+1));35 ans=max(ans, f(n-1, k-n+1));36 printf("%I64d\n", ans);37 }38 39 return 0;40 }
View Code

 

转载地址:http://prxso.baihongyu.com/

你可能感兴趣的文章
LeetCode OJ:Peeking Iterator(peeking 迭代器)
查看>>
对nginx中location的认识
查看>>
通过url获取图片尺寸的几种方法:JS和php
查看>>
WebApi && Swagger 及Swagger配置
查看>>
Gitlab Issue Tracker and Wiki(二)
查看>>
header 里面的content-type
查看>>
Jmeter安装出现Not able to find Java executable or version问题解决方案
查看>>
基于神念TGAM的脑波小车(2)
查看>>
android获取系统wifi状态等
查看>>
js 设计模式
查看>>
HDU-3787(字符串模拟)
查看>>
十四、oracle 数据库管理--管理表空间和数据文件
查看>>
机器学习方法--分类、回归、聚类
查看>>
结构模式讨论
查看>>
[JLOI2011]飞行路线
查看>>
C#装箱和拆箱
查看>>
1.3:Render Pipeline and GPU Pipeline
查看>>
css清除浮动
查看>>
export与import
查看>>
PHP foreach 循环使用"&$val" 地址符“&”
查看>>