Consider the problem of neatly printing a paragraph with a monospaced font (all characters having the same width) on a printer. The input text is a sequence of n words of lengths l1; l2; ···; ln, measured in characters. We want to print this paragraph neatly on a number of lines that hold a maximum of M
算法导论第三版15-4整齐打印Printing neatly
最新推荐文章于 2022-09-17 16:07:08 发布
本文探讨了如何使用动态规划算法来解决在单行打印带等宽字体的段落时,保持整洁并最小化除最后一行外所有行尾额外空格立方和的问题。算法考虑了每行最多容纳M个字符,并且在单词间保留一个空格。通过分析运行时间和空间需求,提供了算法思路,但未提供具体实现代码。


480

被折叠的 条评论
为什么被折叠?



