首页 > 代码库 > Codeforces 450 C. Jzzhu and Chocolate

Codeforces 450 C. Jzzhu and Chocolate

//area=(n*m)/ ((x+1)*(k-x+1)) 
//1: x==0;
//2: x=n-1
//3: x=m-1
# include <stdio.h>
long long max(long long x,long long y)
{
	return x>y?x:y;
}
int main()
{
	long long  n,m,k,sum,t,ans;
	scanf("%lld%lld%lld",&n,&m,&k);
	sum=n+m-2;
	if(k>sum)
		printf("-1\n");
	else if(sum==k)
		printf("1\n");
	else
	{
		ans=0;
		if(n>=k+1)//x=0
		{
			ans=max(ans,m*(n/(k+1)));
		}
		else//x=n-1
		{
			t=k-n+2;
			ans=max(ans,m/t);
		}
		if(m>=k+1)//x=0
		{
			ans=max(ans,n*(m/(k+1)));
		}
		else//x=m-1
		{
			t=k-m+2;
			ans=max(ans,n/t);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Codeforces 450 C. Jzzhu and Chocolate