TOJ 2541: Paper Cutting
2541: Paper Cutting 
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
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 ;
}
TOJ 2541: Paper Cutting的更多相关文章
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- Chinese culture
文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...
- OJ题解记录计划
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001 A+B Problem First AC: 2 ...
- 【AtCoder】KEYENCE Programming Contest 2019
A - Beginning 这个年份恐怕需要+2 #include <bits/stdc++.h> #define fi first #define se second #define p ...
- AtCoder Beginner Contest 058 ABCD题
A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...
- TOJ 2944 Mussy Paper
2944. Mussy Paper Time Limit: 2.0 Seconds Memory Limit: 65536K Special JudgeTotal Runs: 381 ...
- CF Playing with Paper
Playing with Paper time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #296 (Div. 2) A. Playing with Paper
A. Playing with Paper One day Vasya was sitting on a not so interesting Maths lesson and making an o ...
- Cutting Codeforces Round #493 (Div. 2)
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...
随机推荐
- 洛谷 P1474 货币系统 Money Systems
P1474 货币系统 Money Systems !! 不是noip2018的那道题. 简单的多重背包的变式. #include <iostream> #include <cstdi ...
- 图片压缩(pc端和移动端都适用)
最近在做移动端遇到了一个问题就是: 手机拍照后,图片过大如果上传到服务器务必会浪费带宽,最重要的是流量啊 别慌,好事儿来了,务必就会有人去研究研究图片的压缩: 鄙人结合前人的经验,结合自己实战,总结出 ...
- 在一个工程中同时使用Swift和Objective-C
Swift 与 Objective-C 的兼容能力使你可以在同一个工程中同时使用两种语言.你可以用这种叫做 mix and match 的特性来开发基于混合语言的应用,可以用 Swfit 的最新特性实 ...
- Python-OpenCV:cv2.imread(),cv2.imshow(),cv2.imwrite()
为什么使用Python-OpenCV? 虽然python 很强大,而且也有自己的图像处理库PIL,但是相对于OpenCV 来讲,它还是弱小很多.跟很多开源软件一样OpenCV 也提供了完善的pytho ...
- python基础一 day11 装饰器(1)
接收的时候是聚合,调用的时候是打散 print(*args)本来在里面用的时候是用args,是一个元祖,加上一个 * 号,把元祖解包了(打散了). from functools import ...
- OpenCV2:总结篇 core模块
一.cv::Mat 1.作用 cv::Mat表示图像类,用来操作图像和矩阵,它包含很多属性和方法 2.构造方法 cv::Mat image; //cv::Mat image() 无参数构造 ...
- VS打包软件部署------ClickOnce应用安装 (各版本.net引导文件安装,再发布文档离线安装下载地址)
一.1.其他引导程序包:地址 https://msdn.microsoft.com/zh-cn/vstudio/bb898654.aspx 2.离线安装各版本.net下载版(各种语言):https: ...
- webuploader项目中多文件上传实例
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- NoSQL 之 Morphia 操作 MongoDB
上两篇文章:http://www.cnblogs.com/hoojo/archive/2011/06/01/2066426.html http://www.cnblogs.com/hoojo/arch ...
- Shell脚本调用SQL文格式
Shell脚本调用SQL文格式 1. 定义需要执行的SQL文,以及需要输出文件 OUTFILE=\${DATADIR}/\${FILENAME} SQLFILE=\${DATADIR}/check_t ...