随笔分类 -  其他

摘要:该题题义为有一只青蛙要过河,这条和有一个宽度,河中间有若干块石头,青蛙要求在m步的限制下跳跃到河对岸去,问在何种情况下,青蛙能够跳跃到河对岸,并且该方案中跳跃最远的一步数值最小(意思是说这种方案下对青蛙的跳跃能力的要求是最低的)。我们用二分答案的方式来解决这道题,其值可能存在的区间为 0到河的宽度L,对于这个区间中的某一个值,通过已知石头的分布来评价这个方案是否较优,那就是确定了跳跃的最大的距离,那么就让这只青蛙的允许的情况下,跳跃尽可能多的石头。再确定是否在规定的步数中跳到了对岸。代码如下:#include <cstring>#include <cstdlib>#in 阅读全文
posted @ 2012-03-19 16:42 沐阳 阅读(892) 评论(0) 推荐(0)
摘要:Ackerman函数 Ackerman函数定义如下:A(1, 0) = 2A(0, m) = 1 m >= 0A(n, 0) = n + 2 n >= 2A(n, m) = A(A(n-1, m), m-1) n, m >= 1Ackerman函数的反函数 ackerman函数的反函数——α(x)增长极为缓慢。对于可以想象到的n,α(n)都是在5之内的用途 并查集的“路径压缩”算法:在集合的查找过程中顺便将树的深度降低。采用路径压缩后,每一次查询所用的时间复杂度为增长极为缓慢的ackerman函数的反函数——α(x)。对于可以想象到的n,α(n)都是在5之内的。 阅读全文
posted @ 2012-03-01 21:08 沐阳 阅读(3077) 评论(0) 推荐(1)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2601 题意:是将一个数 N 分解成 i * j + i + j 有多少种分解方式。 思路:以 i 作为一个维度,j 作为第二维度进行循环,则 N = i * j + i + j = i * (j + 1) + i ; 当 j = j+ 1 时 N' = i * (j + 1) + i + j + 1 = N + i + 1; 所以只要进行一为循环就可以了,判定 ( N - i ) % (i + 1) == 0 ? 就可以了。 代码:#include <cstdio>#include &l 阅读全文
posted @ 2011-12-02 20:19 沐阳 阅读(364) 评论(0) 推荐(0)
摘要:Immediate DecodabilityAn encoding of a set of symbols is said to be immediatelydecodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at le. 阅读全文
posted @ 2011-09-07 00:10 沐阳 阅读(802) 评论(0) 推荐(0)
摘要:该题就是判定一个所给定串集中是否有某些串是另外一些串的前缀串的问题。字典树的话很好办只要判定在构建一个串的路径中是否已经有的节点被标记(此处有串结尾)和如果一个串在该处结尾,那么是否它的的孩子都为空。 这里写了一个暴力版,即现将所给定的所有数字用long long型存储起来,再按从小到大的顺序进行排序,之后再判定一个字符串以及它的依次去掉末位的子串是否已经存在,如果存在则输出NO,否则输出YES。在这里有一个如果不做一些处理的话是会WA的,那就是在每个数组之前加上一个1,这样使的串中的前导零有意义。 代码如下: 1 #include <cstring> 2 #include < 阅读全文
posted @ 2011-09-03 22:28 沐阳 阅读(316) 评论(0) 推荐(0)
摘要:这题就直接用Java水过了,利用BigDecimal 类型,但是还是有一种情况会判断出错,就是输入 0.0 和 0 ,程序会认为不相等,可能是由于在去除后导零的时候是在寻找前面的非零数字吧。解决的办法是先给 a , b 两个数都加上 1,判断是否相等。但是这样 -1.0 和 -1 又会判断错误了,没事,再分别加上一个1就可以了。 代码如下:import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(Str. 阅读全文
posted @ 2011-08-15 17:19 沐阳 阅读(501) 评论(0) 推荐(0)
摘要:汉诺塔IIITime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3657Accepted Submission(s): 1668Problem Description约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下、由小到大顺序串着由64个圆盘构成的塔。目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动一个盘,且不允许大盘放在小盘的上面。现在我们改变游戏的玩法,不允许直接从最左(右)边移到最右(左) 阅读全文
posted @ 2011-08-12 21:49 沐阳 阅读(3968) 评论(0) 推荐(0)
摘要:1558: Count CyclesTime Limit: 1 SecMemory Limit: 128 MBSubmit: 84Solved: 21[Submit][Status][Web Board]DescriptionIn information theory, a low-density parity-check (LDPC) code is a linear error correcting code, a method of transmitting a message over a noisy transmission channel, and is constructed u 阅读全文
posted @ 2011-08-02 19:22 沐阳 阅读(287) 评论(0) 推荐(0)
摘要:The 3n + 1 problemTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8771Accepted Submission(s): 3203Problem DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In 阅读全文
posted @ 2011-07-31 15:28 沐阳 阅读(1472) 评论(0) 推荐(0)
摘要:1551: ETime Limit: 1 SecMemory Limit: 128 MBSubmit: 28Solved: 4[Submit][Status][Web Board]DescriptionThe Royal Canadian Mint has commissioned a new series of designer coffee tables, with legs that are constructed from stacks of coins. Each table has four legs, each of which uses a different type of 阅读全文
posted @ 2011-07-30 19:53 沐阳 阅读(321) 评论(0) 推荐(0)
摘要:Double QueueTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 4628Accepted: 2130DescriptionThe new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern information technologies. 阅读全文
posted @ 2011-07-29 11:15 沐阳 阅读(574) 评论(0) 推荐(0)
摘要:Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3902Accepted Submission(s): 1621Problem DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woo. 阅读全文
posted @ 2011-07-10 11:57 沐阳 阅读(1266) 评论(0) 推荐(0)