Posted on 2010-08-11 14:36
Uriel 閱讀(371)
評論(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;
}