画外音:没想做到15-2题也是费了一番周折,看来《算法导论》里题都不是白给的 整齐打印问题:考虑在一个打印机上整齐地打印一段文章的问题。输入的正文是n个长度分别为L1、L2、……、Ln(以字符个数度量)的单词构成的序列。我们希望将这个段落在一些行上整齐地打印出来,每行至多M个字符。“整齐度”的标.....
分类:
编程语言 时间:
2015-03-18 23:10:15
阅读次数:
494
The prioritization of large memory page mapping is a function of the access bits in the L1 page table. In a first phase of operation, the number of se...
分类:
其他好文 时间:
2015-03-18 17:41:25
阅读次数:
133
Given a singly linked list L: L0→L1→…→Ln?1→LnL_0→L_1→…→L_{n-1}→L_n,
reorder it to: L0→Ln→L1→Ln?1→L2→Ln?2→…L_0→L_n→L_1→L_{n-1}→L_2→L_{n-2}→…You must do this in-place without altering the nodes’ values....
分类:
其他好文 时间:
2015-03-18 12:34:10
阅读次数:
240
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For e...
分类:
其他好文 时间:
2015-03-18 06:26:57
阅读次数:
109
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes’ values.
For example,
Given {1,2,3,4},...
分类:
其他好文 时间:
2015-03-17 23:51:32
阅读次数:
344
题意:给出两个长度分别为n1,n2且每列高度只为1,或者2的长条,需要将它们放入一个高度为3的容器,问容器的最短长度。分别以s,为标准,平移,得出一个长度l1,再以t为标准,得出一个长度l2,取len=min(len1,len2),再取len=max(max(n1,n2),len)(因为还是要覆盖住...
分类:
其他好文 时间:
2015-03-17 21:50:15
阅读次数:
170
1.题目描述:点击打开链接
2.解题思路:本题算是一道微积分题目,首先根据题目条件列写方程:间隔数n=ceil(B/D),每个间隔宽度D1=B/n,每段绳索长度L1=L/n。接下来就是根据D1,L1来计算底部离地面的高度y了。不过我们会发现,这个方程很难找到求解公式,因此应该转移思路,试图利用数值问题中的二分法逐渐逼近这个高度值。设函数P(w,h)计算出来抛物线的长度,其中w表示抛物线开口的宽度...
分类:
其他好文 时间:
2015-03-17 14:16:13
阅读次数:
140
描述在xoy直角坐标平面上有n条直线L1,L2,…Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为可见的,否则Li为被覆盖的.
例如,对于直线:
L1:y=x; L2:y=-x; L3:y=0
则L1和L2是可见的,L3是被覆盖的.
给出n条直线,表示成y=Ax+B的形式(|A|,|B|<=500000),且n条直线两两不重合.求出所有可见...
分类:
其他好文 时间:
2015-03-16 23:17:30
阅读次数:
386
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam...
分类:
其他好文 时间:
2015-03-16 22:44:06
阅读次数:
139
首先是归并排序,基本思想为分治,合并的技巧比较重要,不是原址排序。代码如下;int merge(int* x,int left,int mid,int right)
{
int i,j,k;
int L1 = mid-left+2;
int L2 = right-mid+1;
int* L = new int[L1];
int* R = new int[L2]...
分类:
编程语言 时间:
2015-03-15 15:24:06
阅读次数:
184