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;
}

时间: 2024-11-14 12:36:37

Codeforces 450 C. Jzzhu and Chocolate的相关文章

Codeforces 450C:Jzzhu and Chocolate(贪心)

C. Jzzhu and Chocolate time limit per test: 1 seconds 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 exact

codeforces 450 B Jzzhu and Sequences

题意:给出f1=x,f2=y,f(i)=f(i-1)+f(i+1),求f(n)模上10e9+7 因为 可以求出通项公式:f(i)=f(i-1)-f(i-2) 然后 f1=x; f2=y; f3=y-x; f4=-x; f5=-y; f6=-y+x; f7=x; 发现是以6为循环的 还有注意下余数为正,就每次加上一个mod再模上mod 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #includ

Codeforces Round #257 (Div. 2)449A - Jzzhu and Chocolate(贪心、数学)

题目链接:http://codeforces.com/problemset/problem/449/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943

CodeForces 449A - Jzzhu and Chocolate

传送门:Jzzhu and Chocolate 题意: 给出一个N * M的矩阵,给K个操作,每次操作可以横/竖切割矩阵,最后求K次切割之后,矩阵最小的那块面积最大是多少? 分析: 按照题意,题目求的结果是:(最小的面积,最大是多少),那么可以想到,K次切割之后尽量使得每个块的面积相等,某些块比较大(因为不一定能平均分),那么就可以使得最小的那块面积最大了. 然后如何切割呢? 因为有横竖两个切割方法,那么我们可以设X为横切割数,Y为竖切割数,其中(0 <= X, Y <= K),因为最多对一个

Codeforces 449D:Jzzhu and Numbers

Codeforces 449D:Jzzhu and Numbers 题目链接:http://codeforces.com/problemset/status?friends=on 题目大意:给出$n$个数,求有多少种组合使得$a_{i_1}\&a_{i_2}\&...\&a_{i_k}=0(0 \leqslant i < n)$,答案对$10^9+7$取模. 容斥原理+DP 设位与$(\&)$后二进制表示中有$k$个$1$的组合数为$A_k$,则有, $A_0=$所有

Codeforces 450(#257 (Div. 2) ) 解题报告

A: 1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2014年07月19日 星期六 21时01分28秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque> 10 #include<stack> 11 #include<bits

Codeforces449A Jzzhu and Chocolate &amp;&amp; 449B Jzzhu and Cities

CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀,那么答案应该是 (n/(k1+1)) * (m/(k2+1)),除法是取整的.虽然是取整,但是不难发现其实就是要(k1+1)*(k2+1)最小,根据均值不等式,k1+k2=k(定值) k1==k2的时候(k1+1)*(k2+1)=k1*k2+k1+k2+1=k1*k2+k+1应该是取最大值,所以当k

CodeForces 450

A - Jzzhu and Children Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th

449A - Jzzhu and Chocolate 贪心

一道贪心题,尽量横着切或竖着切,实在不行在交叉切 #include<iostream> #include<stdio.h> using namespace std; int main(){ // freopen("in.txt","r",stdin); long long n,m,k; while(cin>>n>>m>>k){ if((n+m-2)<k){ printf("-1\n"