随笔分类 -  HDU OJ

摘要:我们经常会用到递归的思想去解决问题,比如说经典的汉诺塔问题、斐波拉契数列问题、二叉树的递归遍历。。。。。 虽然递归的思想比较直接容易,但是我们知道用递归的效率是很低的。所以我们也经常去探索将递归转换成迭代的方法,下面介绍一类问题的递归-数学转换: 我们先来看这样一个情景: 阅读全文
posted @ 2013-05-21 02:18 Cocoon 阅读(505) 评论(0) 推荐(0)
摘要:Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 75924 Accepted Submission(s): 17659 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). Input The input consists of multiple test cases 阅读全文
posted @ 2013-04-04 20:29 Cocoon 阅读(369) 评论(1) 推荐(0)