随笔分类 -  学习笔记

摘要:Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given s... 阅读全文
posted @ 2015-05-29 12:12 Cizel丶攻城狮 阅读(405) 评论(0) 推荐(0)
摘要:Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6,... 阅读全文
posted @ 2015-05-28 01:28 Cizel丶攻城狮 阅读(1988) 评论(0) 推荐(0)
摘要:Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "ins... 阅读全文
posted @ 2015-03-05 14:42 Cizel丶攻城狮 阅读(815) 评论(0) 推荐(0)
摘要:Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135... 阅读全文
posted @ 2015-03-05 13:26 Cizel丶攻城狮 阅读(407) 评论(1) 推荐(0)
摘要:一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……AN-1)变换为(AN-M …… AN-1 A0 A1……AN-M-1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移... 阅读全文
posted @ 2015-03-05 11:12 Cizel丶攻城狮 阅读(274) 评论(0) 推荐(0)
摘要:让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数。显然有 d1=1 且对于n>1有 dn 是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N (#includeusing namespace std;int main(){ int nu... 阅读全文
posted @ 2015-03-05 10:54 Cizel丶攻城狮 阅读(211) 评论(0) 推荐(0)
摘要:本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。 给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。 输入格式: 输入在一行给... 阅读全文
posted @ 2015-03-05 00:22 Cizel丶攻城狮 阅读(504) 评论(0) 推荐(0)
摘要:Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 using namespace std;int Ma... 阅读全文
posted @ 2015-03-04 22:54 Cizel丶攻城狮 阅读(482) 评论(0) 推荐(0)
摘要:给定K个整数组成的序列{ N1, N2, ..., NK },“连续子列”被定义为{ Ni, Ni+1, ..., Nj },其中 1 using namespace std;int MaxsubseqSum1(int a[],int k){ int ThisSum=0,MaxSum=0; fo... 阅读全文
posted @ 2015-03-04 13:42 Cizel丶攻城狮 阅读(349) 评论(0) 推荐(0)