2 shunfurh shunfurh 于 2017.01.07 11:52 提问

Cutting a Block

Description

Carpenter Bill has a huge wooden block. The block has a shape of rectangular parallelepiped.

The block is so huge that it cannot pass through the door of Bill’s house. So he decided to cut it into n smaller blocks. Bill is not a very smart guy so he wants to make all small blocks rectangular, and all of them should be equal.

Write a program that would help Bill to cut his block.

Input

Let us introduce a coordinate system such that the edges of the block are parallel to the coordinate axes and one of the block’s corners is placed at the origin. The opposite corner of the block has coordinates (x, y, z).

The first line of the input file contains four integer numbers — x, y, z and n (1 ≤ x, y, z, n ≤ 1 000).

Output

Output file should contain n lines each describing one small block. Each small block is described by six numbers: x1, y1, z1, x2, y2, z2, where (x1, y1, z1) are the coordinates of one corner of the block and (x2, y2, z2) are the coordinates of its opposite corner.

Coordinates must be precise up to eight digits after the decimal point.

Sample Input

sample input #1
3 2 2 4

sample input #2
3 2 2 6
Sample Output

sample output #1
0 0 0 1.5 1 2
3 0 0 1.5 1 2
0 1 0 1.5 2 2
3 1 0 1.5 2 2

sample output #2
0 0 0 1 2 1
0 0 1 1 2 2
1 0 0 3 1 1
1 0 1 3 1 2
1 1 0 3 2 1
1 1 1 3 2 2Cutting a Block

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.13 23:51
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
DP 算法: cutting a rod
给定一个问题, 能够使用动态规划的
Cutting CodeForces - 998B (思维)
B. Cuttingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are a lot of things which could be cut — trees, paper, "the rope". In this problem...
算法之动态规划-Rod cutting
问题描述:给定长度为n的木头,把它切分成小段卖,不同长度的木头价格不一样,求最优切法。如图1: 可以划分为如下情况 分为一份: 4 (max price:10) 分为两份 : 1 3 or 2 2 or 3 1 (max price:10) 分为三份 : 1 1 2 or 1 2 1 or 2 1 1 (max price:7) 分为四分 : 1 1 1 1 (max pric
Cutting stock
1. 问题描述Suppose that you have been assigned the job of buying the plumbing pipes for a construction project. Your foreman gives you a list of the varying lengths of pipe needed, but the distributor sell
Codeforces round 493 div2 B.Cutting (贪心技巧)
B. Cuttingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are a lot of things which could be cut — trees, paper, "the rope". In this problem...
998B Cutting
B. Cuttingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are a lot of things which could be cut — trees, paper, "the rope". In this problem...
CodeForces 955D Scissors(字符串哈希)
学多了高级的东西,别忘了简单的…… 大致题意,给出一个字符串,你有一把剪刀可以把字符串剪成两个不想交的长度为K的字符串,然后把两个拼起来。现在要你给出一种剪法使得拼接之后的字符串包含另一个新的字符串。 其实不用想什么高级的算法,直接暴力即可。考虑第二个字符串的每一个前缀和后缀,我可以找到起点最左(右)的一个点,使得从这个点开始的长度为k的串的后(前)缀是我们要求的前缀和后缀。寻找的话利用双指针很快,1~i-1的前缀的位置求出来之后,1~i的前缀的位置肯定在1~i-1之后,然后一
算法导论 第十五章:动态规划之棒的切割(Rod Cutting)
和分治法一样,动态规划(Dynamic programming)是通过组合子问题的解而解决整个问题的。 其不同点在于: 1)分治法是将问题划分成一些独立的子问题,递归求解各个子问题,然后合并子问题的解而得到原问题的解 2)动态规划使用于子问题不独立的情况,也就是各个子问题包含公共的部分。若采用分治法,会有重复的求解公共部分,而动态规划算法对每个子问题只求解一次,然后抢劫过保存在一张表中,从而
Doug Cutting (Lucene-Nutch-Hadoop 创始人简介)
吃水不忘挖井人,介绍Doug Cutting大牛是十分有必要的。      最早,接触到搜索引擎,知道有个Nutch(开源搜索引擎),于是开始查看Nutch相关的资料,发现了Nutch的创始人Doug Cutting,随着项目的深入,发现Doug Cutting本人不仅是Nutch的创始人,还是Lucene(开源的全文检索包)项目的创始人,之后Doug Cutting加入Yahoo,06年成
Codeforces 963C. Cutting Rectangle
感谢lxy教会我这题qaq w和h具体是什么不重要,先将他们离散化,然后把c[i]记成c[w][h]的形式 如果有某个c[w][h]=0一定不合法,并且c[w][1]:c[w][2]:....c[w][h]c[w][1]:c[w][2]:....c[w][h]c[w][1]:c[w][2]:....c[w][h]这个比例对所有w相同,这样才存在合法方案 单独考虑一种方块c[w][h],可...