Posted on 2010-08-11 14:36
Uriel 阅读(352)
评论(0) 编辑 收藏 引用 所属分类:
POJ 、
模拟
又是一道去年没切掉的模拟,去年大略看了一下,题目不是很懂就没做。
今天又翻出来这道题。。果真大水。。= =
题意是印刷切割名片,印的时候要A*B张一起印刷,每张名片大小为C*D,印刷纸张大小E*F,问印完之后至少切一刀能把名片都分开(不能把名片叠在一起一刀切),明白意思之后就显然大水一道了~~
//Problem: 1791 User: Uriel
//Memory: 368K Time: 0MS
//Language: G++ Result: Accepted
//Simulation
//2010.08.11
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define INF 100000000
int A,B,C,D,E,F,minx,cut;
int main(){
int hh,ww;
while(scanf("%d %d %d %d %d %d",&C,&D,&A,&B,&E,&F),A|B|C|D|E|F){
minx=INF;
if(A>B)swap(A,B);
if(C>D)swap(C,D);
if(E>F)swap(E,F);
//-----------------------------------------------case 1
cut=0;
hh=A*C;ww=B*D;
if(hh>E || ww>F)goto case2;
if(E>hh)cut++;
if(F>ww)cut++;
cut+=C*D-1;
if(cut<minx)minx=cut;
//-----------------------------------------------case 2
case2: cut=0;
hh=A*D;ww=B*C;
if(hh>ww)swap(hh,ww);
if(hh>E || ww>F)goto flag;
if(E>hh)cut++;
if(F>ww)cut++;
cut+=C*D-1;
if(cut<minx)minx=cut;
flag: if(minx<INF)printf("The minimum number of cuts is %d.\n",minx);
else
puts("The paper is too small.");
}
return 0;
}