2541: Paper Cutting 

Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByte
Total Submit: 1            Accepted:1

Description

ACM managers need business cards to present themselves to their customers and partners. After the cards are printed on a large sheet of paper, they are cut with a special cutting machine. Since the machine operation is very expensive, it is necessary to minimize the number of cuts made. Your task is to find the optimal solution to produce the business cards.

There are several limitations you have to comply with. The cards are always printed in a grid structure of exactly a * b cards. The structure size (number of business cards in a single row and column) is fixed and cannot be changed due to a printing software restrictions. The sheet is always rectangular and its size is fixed. The grid must be perpendicular to the sheet edges, i.e., it can be rotated by 90 degrees only. However, you can exchange the meaning of rows and columns and place the cards into any position on the sheet, they can even touch the paper edges.

For instance, assume the card size is 3 * 4 cm, and the grid size 1 * 2 cards. The four possible orientations of the grid are depicted in the following figure. The minimum paper size needed for each of them is stated.


The cutting machine used to cut the cards is able to make an arbitrary long continuous cut. The cut must run through the whole piece of the paper, it cannot stop in the middle. Only one free piece of paper can be cut at once -- you cannot stack pieces of paper onto each other, nor place them beside each other to save cuts.

Input

The input consists of several test cases. Each of them is specified by six positive integer numbers, A,B,C,D,E,F, on one line separated by a space. The numbers are: 
A and B are the size of a rectangular grid, 1 <= A,B <= 1 000, 
C and D are the dimensions of a card in cms, 1 <= C,D <= 1 000, and 
E and F are the dimensions of a paper sheet in cms, 1 <= E,F <= 1 000 000. 
The input is terminated by a line containing six zeros.

Output

For each of the test cases, output a single line. The line should contain the text: "The minimum number of cuts is X.", where X is the minimal number of cuts required. If it is not possible to fit the card grid onto the sheet, output the sentence "The paper is too small." instead.

Sample Input

Sample Output

Source

CTU Open 2003

Tag

要切一种卡片 纸张大小事px,py
格子大小gx,gy 卡片要cx,xy;
于是每次就要切出gx*gy个大小为cx*cy的卡片 问最少切几次
关键是:
1:一次只能切连续,不能在中间中断 故只能一横或一竖切下来
2:每次只能切连在一起的纸 若你之前被切开的则不能一起切 当然纸张更不能折叠来切
(观察sample就可以知道了,然后对于大小为n*m的格子只要切n*m-1次就行了当然还要再检验一下边角需不需要切)
枚举所有情况啊
#include<stdio.h>
int a,b,c,d,e,f;
const int INF=<<;
int la(int w,int x,int y,int z)
{
if(w*y>e||x*z>f)return INF;
return w*x-+(w*y<e)+(x*z<f);
}
int main()
{
while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a||b||c||d||e||f)
{
int m=la(a,b,c,d),x;
if((x=la(b,a,c,d))<m)m=x;
if((x=la(a,b,d,c))<m)m=x;
if((x=la(b,a,d,c))<m)m=x;
if(m==INF)printf("The paper is too small.\n");
else printf("The minimum number of cuts is %d.\n",m);
}
return ;
}

最新文章

  1. 【Win10开发】Toast通知
  2. MongoDB学习笔记~环境搭建
  3. LayoutInflater和inflate()
  4. 检查python模块是否成功安装
  5. SQL中Group By 的使用
  6. Debian 6配置GNOME桌面环境
  7. C语言结构
  8. linux动态库加载RPATH, RUNPATH
  9. Spring Boot 属性配置和使用(转)
  10. d3.js 绘制极坐标图(polar plot)
  11. 关于node的基础理论,书上看来的
  12. mysql常用基础操作语法(三)~~对数据的增删改操作【命令行模式】
  13. 【SW4STM32生成 hex文件的设置方法】
  14. matlab-双摆仿真
  15. KVM虚拟化概述与安装
  16. centos 6.9修改系统默认字符集
  17. Ubuntu18系统qt生成程序无法双击运行问题
  18. SpringBoot2.x整合Redis实战 4节课
  19. JSON 使用 教程
  20. STL 算法介绍

热门文章

  1. ES6中新增的字符串方法
  2. map中使用await 异步函数
  3. 《深入理解JavaScript闭包和原型》笔记
  4. Python实现扫描作业配置自动化
  5. codevs 1277 生活大爆炸 2012年CCC加拿大高中生信息学奥赛
  6. shell批量转换iOS和Android图标
  7. jquery实现跑马灯效果(一)
  8. CPP-基础:strcpy之于C++(
  9. ios runloop学习
  10. ios之UITextView