上一页 1 ··· 9 10 11 12 13
摘要: Problem DescriptionLet S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence). q By an integer sequence W = w1 w2...wn where 阅读全文
posted @ 2013-07-30 22:08 秋心无波 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionCurrent work in cryptography involves (among other things) large prime numbers and computing powers of numbers among these primes. Work in this area has resulted in the practical use of results from number theory and other branches of mathematics once considered to be only of theo 阅读全文
posted @ 2013-07-30 09:20 秋心无波 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a 阅读全文
posted @ 2013-07-28 19:16 秋心无波 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 【题目描述】 小M很喜欢找点游戏自娱自乐。有一天,她在纸上写了一串数字:1,1,2,5,4。接着她擦掉了一个1,结果发现剩下1,2,4都在自己所在的位置上,即1在第1位,2在第2位,4在第4位。她希望擦掉某些数后,剩下的数列中在自己位置上的数尽量多。她发现这个游戏很好玩,于是开始乐此不疲地玩起来……不过她不能确定最多能有多少个数在自己的位置上,所以找到你,请你帮忙计算一下!【输入格式】第一行为一个数n,表示数列的长度。接下来一行为n个用空格隔开的正整数,第i行表示数Ai。【输出格式】一行一个整数,表示擦掉某些数后,最后剩下的数列中最多能有多少个数在自己的位置上,即Ai=i最多能有多少。【样例输 阅读全文
posted @ 2013-07-27 19:57 秋心无波 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 广度优先搜索详解 1. 也称宽度优先搜索,顾名思义,就是将一棵树一层一层往下搜。算法首先搜索和s距离为k的所有顶点,然后再去搜索和S距离为k+l的其他顶点。BFS是一种完备策略,即只要问题有解,它就一定可以找到解。并且,广度优先搜索找到的解,还一定是路径最短的解。但是它盲目性较大,尤其是当目标节点距初始节点较远时,将产生许多无用的节点,因此其搜索效率较低。需要保存所有扩展出的状态,占用的空间大。 一般需求最优解的时候用广搜。搜索过程是:从初始节点S0开始逐层向下扩展,在第n层节点还没有全部搜索完之前,不进入第n+1层节点的搜索。假设有两个表:Open表存放待处理节点,Closed表存放处... 阅读全文
posted @ 2013-07-24 12:10 秋心无波 阅读(5115) 评论(0) 推荐(0) 编辑
摘要: 881. 麦香牛块★ 输入文件:nuggets.in 输出文件:nuggets.out 简单对比 时间限制:1 s 内存限制:128 MB描述农夫布朗的奶牛们正在进行斗争,因为它们听说麦当劳正在考虑引进一种新产品:麦香牛块。奶牛们正在想尽一切办法让这种可怕的设想泡汤。奶牛们进行斗争的策略之一是“劣质的包装”。“看,”奶牛们说,“如果你只用一次能装3块、6块或者10块的三种包装盒包装麦香牛块,你就不可能满足一次只想买1、2、4、5、7、8、11、14或者17块麦香牛块的顾客了。劣质的包装意味着劣质的产品。”你的任务是帮助这些奶牛。给出包装盒的种类数N(1 2 #include 3 #includ 阅读全文
posted @ 2013-06-30 17:07 秋心无波 阅读(394) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13