PAT 1086 Tree Traversals Again题目:An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that wh...
分类:
其他好文 时间:
2014-09-07 11:02:25
阅读次数:
183
记得在我们最开始学习C语言的时候,每当讲到递归,无论是课本上,还是老师,都会给出两个经典例子的递归实现,其中一个就是阶乘,另外一个就是Fibonacci(中文多译成斐波那契)数列了。用递归方法计算阶乘的代码如下://递归计算阶乘long Factorial(int n){ if (n 1) { r....
分类:
其他好文 时间:
2014-09-05 23:46:32
阅读次数:
252
题目链接
题意:g(x) = k * x + b。f(x) 为Fibonacci数列。求f(g(x)),从x = 1到n的数字之和sum,并对m取模。
思路:
设A = |(1, 1),(1, 0)|
sum = f(b) + f(k + b) + f(2k + b)...+f((n-1)k + b) (f(x) 为Fibonacci数列)
sum = A^...
分类:
其他好文 时间:
2014-09-03 22:49:07
阅读次数:
314
HDU 1250 Hat's Fibonacci(Java大数相加)+讲解...
分类:
编程语言 时间:
2014-09-03 19:51:57
阅读次数:
341
Fibonacci数列及其相关的数学问题,如何判断一个数是否是斐波那契数列...
分类:
其他好文 时间:
2014-09-03 16:51:36
阅读次数:
289
题目:求第n个Fib数与2^m的模。
分析:分治,快速幂。
具体参照本人的 斐波那契数列(http://blog.csdn.net/mobius_strip/article/details/8222309)
中 4.Fib的计算3:分治法;
设Jn为第n个月有生育能力的兔子数量,An为这一月份的兔子数量。得到如下递推矩...
分类:
其他好文 时间:
2014-09-03 13:13:16
阅读次数:
220
There cheap ghd hair straighteners has never been anyone else like you on the earth nor will there ever be again. And unless you are the identical twi...
分类:
其他好文 时间:
2014-09-02 15:27:04
阅读次数:
271
直接从前往后DP,因为一共只有500个数,所以累加起来的话单个数不会超过4096,并且因为是Flappy 2048的规则,所以只有之后数列末尾一串递减的是有效的,因此可以状压。1700ms = =,据说用滚动数组优化一下会好很多#include #include #include #include ...
分类:
其他好文 时间:
2014-09-01 20:55:43
阅读次数:
221
letshabiNumbers=["prime":[2,3,5,7,11,13],"Fibonacci":[1,1,2,3,4,8],"Square":[1,4,9,16,25],]varlargest=0varbigerkind=0vartemp=0vartag=1;vari=0;vars=""for(kind,numbers)inshabiNumbers{/*fornumberinnumbers{ifnumber>largest{largest=number}}*/fornumberinnumber..
分类:
编程语言 时间:
2014-09-01 15:54:43
阅读次数:
173
本题又是一个典型的KMP应用。
求两个字符串相加的结果,相加的规律是一个字符串的后缀和另一个字符串的前缀相同,就可以合并这个部分。
不过本题的题意不是很清晰,因为没有太明确指出这两个字符串的出现顺序是无关的,只是需要输出合并后长度最短的结果,如果合并后长度一样,那么就按照字典顺序,输出字典顺序在前的字符串。
思路:
1 使用kmp在s2查找s1,那么最终结束的时候next table的值就...
分类:
其他好文 时间:
2014-08-31 17:18:41
阅读次数:
140