Codeforces 450 C. Jzzhu and Chocolate, codeforcesjzzhu

Source: Internet
Author: User

Codeforces 450 C. Jzzhu and Chocolate, codeforcesjzzhu

Quadratic functions n * m/(x + 1) * (k-x + 1) are quadratic functions with symmetric axes> 0 opening down, directly consider x = 0 | x = n-1 | x = M-1 and so on .....


C. Jzzhu and Chocolatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Jzzhu has a big rectangular chocolate bar that consistsNLimit × limitMUnit squares. He wants to cut this bar exactlyKTimes. 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 rows × six 6 chocolate for 5 times.

Imagine Jzzhu have madeKCuts 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 exactlyKCuts? The area of a chocolate piece is the number of unit squares in it.

Input

A single line contains three integersN, Bytes,M, Bytes,K(1 digit ≤ DigitN, Bytes,MLimit ≤ limit 109; 1 limit ≤ limitKLimit ≤ limit 2-109 ).

Output

Output a single integer representing the answer. If it is impossible to cut the big chocolateKTimes, 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 rows × every 3 chocolate 4 times.




#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long int LL;LL n,m,k,ans=0LL;int main(){    cin>>n>>m>>k;    if(n+m-2<k)    {        puts("-1"); return 0;    }    if(n+m-2==k)    {        puts("1"); return 0;    }    LL t;    if(m>=k+1)        ans=max(ans,n*(m/(k+1)));    else    {        t=k-m+1;        ans=max(ans,n/(t+1));    }    if(n>=k+1)        ans=max(ans,m*(n/(k+1)));    else    {        t=k-n+1;        ans=max(ans,m/(t+1));    }    cout<<ans<<endl;    return 0;}





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.