出题:Josephus
Cycle,约瑟夫环问题。k个数字连成一个环,第一个数字为1。首先从1开始计数删除第m个数字;然后从上次被删除的数字的下一个数字开始计数,删除第m个数字;重复进行第二步直到只剩下一个数字;输出最后剩下的一个数字;分析:解法1:考虑到问题的特殊性,可以使用哑元素表示删除的元素从...
分类:
其他好文 时间:
2014-05-27 01:35:42
阅读次数:
251
问题描述Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少。输入格式输入包含一个整数n。输出格式输出一行,包含一个整数,表示Fn除以10007的余数。说明:在本题中,答案是要求Fn除以10007...
分类:
其他好文 时间:
2014-05-26 00:54:58
阅读次数:
265
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a litt...
分类:
其他好文 时间:
2014-05-23 02:27:26
阅读次数:
587
题目:
已知m、n为整数,且满足下列两个条件:
① m、n∈1,2,...,K,(1≤K≤10^9)
② (n^ 2-mn-m^2)^2=1
编一程序,对给定K,求一组满足上述两个条件的m、n,并且使m^2+n^2的值最大。例如,若K=1995,则m=987,n=1597,则m、n满足条件,且可使m^2+n^2的值最大。...
分类:
其他好文 时间:
2014-05-23 00:21:02
阅读次数:
402
题目大意:
描述了另外一种斐波那契
F[n] = x*F[n-1] + y*F[n-2];
求segma(F[i]^2);
思路分析:
构造矩阵的详细
请戳我
构造矩阵可以得到
中间矩阵为
1 1 0
0
0 x^2 y^2 2*x*y
0 1
0 0
0 x
0 y
#include
#include
#include
#...
分类:
其他好文 时间:
2014-05-22 23:43:19
阅读次数:
318
Problem 2: Even Fibonacci numbers
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2,...
分类:
其他好文 时间:
2014-05-22 23:29:44
阅读次数:
435
Dynamic programming and meta-programming to
calculate Fib arrays.
分类:
其他好文 时间:
2014-05-22 01:42:39
阅读次数:
341
本来是想试试在lua里写个简单的scheme解释器,看能精简到什么程度,至少要能跑通一个打印fibonacci数列的测试。结果就写出来个只包含lambda/if两个special
form,以及+-=和print几个内置过程的解释器,只有区区60行代码~ 爱不释手,过个半小时就把代码翻出来臭美下.....
分类:
其他好文 时间:
2014-05-21 14:28:02
阅读次数:
357
上得厅堂,下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练!...
分类:
其他好文 时间:
2014-05-21 14:04:43
阅读次数:
276
Description
In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn ? 1 + Fn ? 2 for n ≥ 2. For example, the first ten terms of
the Fibonacci sequence are:
0, 1, 1, 2, 3, 5, 8, 13, 21, ...
分类:
其他好文 时间:
2014-05-21 09:39:15
阅读次数:
231