摘要: http://poj.org/problem?id=3517 方法:具体参见3750 假设此环为以m+1起始,m-1终止的n-1环,且m+1--->1,求得此环最后出队的编号 再将此编号转换成原n环的编号 注意: 此题m为起始点,k为步长。且首先出队编号m,再以步长k循环 Description Let’s play a stone removing g...
阅读全文
摘要: http://poj.org/problem?id=3278 方法: 单源无权图最短距离,即BFS 该问题只需要求得某两点间的最短距离,所以不必求得所有节点的最短距离,一旦处理了目的地点,即可返回结果 Description Farmer John has been informed of the location of a fugitive ...
阅读全文
摘要: http://poj.org/problem?id=3126 方法: 先筛出1000~9999的所有素数,对于其中每个素数求得他在图中的邻接点。其邻接点就是所有与其有一位不同的素数。 再用BFS搜索图找到指定源节点和目标节点之间的最短路径。若不联通则输出失败 Description The ministers of the cabinet were quite ...
阅读全文
摘要: http://poj.org/problem?id=3087 简单的模拟题,模拟洗牌 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by sta...
阅读全文
摘要: http://poj.org/problem?id=2739 方法: 埃氏筛法得到N以下的所有素数,复杂度n*lglgn 利用积累数组计算数组中连续元素的和 Description Some positive integers can be represented by a sum of one or more consecutive prim...
阅读全文
摘要: http://poj.org/problem?id=2593 Maximum Sequence 求数组两段不重叠的连续子数组的最大和 详见2479 Description Give you N integers a1, a2 ... aN (|ai| <=1000, 1 <= i <= N). You should outpu...
阅读全文
摘要:http://poj.org/problem?id=2499 root为(1,1),节点(a,b)的左孩子为(a+b,b),右孩子为(a,a+b)。求从root到给定节点(a,b)所走过的左右路径各为多少 方法:不断优化算法的经典例子,类似于求最大公约数TLE了几次才逐渐改进的算法:TLE-->0ms详见注释 Description BackgroundBinary trees are a...
阅读全文
摘要: http://poj.org/problem?id=1503 方法: 很简单,模拟手动加法过程, 结果中的前置0要消去 Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of pow...
阅读全文
摘要: http://poj.org/problem?id=1056 方法:Trie树 1、由于编码只由0、1组合,因此Trie的数组分支为2个,即son[2] 2、估计节点数目。已知一个集合中最多有8个序列,每个序列最多有10位。因此最坏情况下共有节点80个。 Description An encoding of a set of symbols ...
阅读全文