Link: http://codeforces.com/problemset/problem/449/A

----------------------------------------------------------------------------------------------------------------------------------------------------------

Welcome to tianci Hut: http://user.qzone.qq.com/593830943/main

----------------------------------------------------------------------------------------------------------------------------------------------------------

A. jzzhu and chocolatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Jzzhu has a big rectangular chocolate bar that consists*N*? ×?*M*Unit squares. He wants to cut this bar exactly*K*Times. Each cut must meet the following requirements:

- Each cut shoshould be straight (horizontal or vertical );
- Each cut shoshould go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut );
- Each cut shoshould 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.

Give a chocolate bar n * m in size. You need to cut K knives on this bar to make the smallest part of the area as large as possible, find the maximum area of the minimum part after dividing. If the chocolate bar cannot be split into k parts,-1 is output. Note that each knife must meet three conditions: 1. Cross-cutting or vertical cutting; 2. Each knife can only pass through the edge of unit square (that is, the Unit bar of 1*1, that is to say, a cell bar cannot be damaged and must be complete. 3. Each knife can only be operated in the whole chocolate bar. That is to say, the four outer edges cannot be split. 4. Each knife is different.

__Ideas__Reprinted__:__

First, you must know when this large bar cannot be cut into k knives. It is easy to know that if k> (n-1) + (m-1), because the four outer sides are not allowed to operate! After we confirm that this cannot be switched, we will discuss it based on N (Strike) or M (Strike. However, since we cannot see at a glance which scheme is better, we have to discuss both of them. At first, I only thought of the two sub-statements in the IF statement, N/(k + 1) it means that all K knives are cross-cutting, and the denominator is k + 1 instead of K, because one knife can divide a region into two parts, and the two knives have three parts, and so on. What we need to require is the area, and we need to use the part instead of the number of knives. M/(k + 1.

However, the problem occurs. Based on the WA result returned by test10, I come up with pai_^. It is possible that the K-knife is not enough for full or vertical cutting! You need to divide the remaining number of knives into vertical cutting (corresponding to the previous full cross cutting) or cross cutting (corresponding to the previous full vertical cutting. That is, the else part of the code. In fact, the complete A1 Expression is like this: N/(n-1) * m/(k-(n-1) + 1), meaning: Completely cross-cutting, can only cut n-1 knife, then the area of the smallest part of the partition acts as 1. M/(k-(n-1) + 1) indicates how many knives can be split by vertical cutting, + 1 refers to the split part, not the number of knives, which is the same as + 1 in N/(k + 1) of if.

(I'm so happy that this question has been ranked by the 26 most frequently used questions. Continue to work hard! ^_^)

The Code is as follows:

#include <cstdio>#include <iostream>#include <algorithm>using namespace std;#define LL __int64int main(){LL n, m, k;LL ans1, ans2;while(~scanf("%I64d%I64d%I64d",&n,&m,&k)){if(n-1+m-1 < k){printf("-1\n");continue;}if(n >= k+1 || m >= k+1){ans1 = n/(k+1)*m;ans2 = m/(k+1)*n;}else{ans1 = n/(k-(m-1)+1)*1;ans2 = m/(k-(n-1)+1)*1;}LL ans = max(ans1, ans2);printf("%I64d\n",ans);}return 0;}

Codeforces round #257 (Div. 2) 449a-jzzhu and chocolate (greedy, math)