一道贪心题,尽量横着切或竖着切,实在不行在交叉切
#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"); continue; } long long max=0,t; if(n>m){ t=m;m=n;n=t; } long long ans; if(m>=(k+1)){ ans=(n/(k+1)*m)>(m/(k+1)*n)?(n/(k+1)*m):(m/(k+1)*n); } else{ ans=(m/(k-(n-1)+1))>(n/(k-(m-1)+1))?(m/(k-(n-1)+1)):(n/(k-(m-1)+1)) ; } cout<<ans<<endl; } }
449A - Jzzhu and Chocolate 贪心,布布扣,bubuko.com
原文地址:http://blog.csdn.net/youngyangyang04/article/details/38034079