摘要: //ans=2*n+(n-1)(n-2) n>=2#include #include #include #include #include #include #include #include #include #include #include #include #include #include... 阅读全文
posted @ 2014-09-19 11:34 Commence 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 考虑最左边一列和最左边两列分别可以一个纵方块;2个横方块+2*2;则f[i]=f[i-1]+2f[i-2];#include #include #include #include #include #include #include #include #include #include #inclu... 阅读全文
posted @ 2014-09-19 11:11 Commence 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题意略;先暴力打表发现规律N=1 ans=1N=2 ans=2N=3 ans=2N=4 ans=4N=5 ans=2N=6 ans=4N=7 ans=6N=8 ans=8N=9 ans=2N=10 ans=4N=11 ans=6N=12 ans=8N=13 ans=10N=14 ans=12N=15... 阅读全文
posted @ 2014-09-18 22:47 Commence 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 题意:N条直线最多把平面分成几个部分ans=1+(N+1)*N/2;直线数量 1 2 3 4 …………n把平面分成的块数 2 4 7 ... 阅读全文
posted @ 2014-09-18 20:34 Commence 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题意讲某个二进制按照规则每一位对应斐波那契数生成新的数字,然后2个数字求和。再求由该规则生成的二进制串。并且要求尽量用更大项的fib数(题目提示不能由连续的1就是2个连续的1(11)不如100更优)用大数处理出100项fib。然后模拟交替置位位0或者1,输出#include #include #in... 阅读全文
posted @ 2014-09-18 13:43 Commence 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 斐波那契取MOD。利用矩阵快速幂取模http://www.cnblogs.com/Commence/p/3976132.html代码:#include #include #include #include #include #include #include #include #include #i... 阅读全文
posted @ 2014-09-17 19:03 Commence 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 自己手动画了第三项发现f[3]=5;就猜斐波那契了。实际上光线分为两种距离外界有2面玻璃,1面玻璃 其分别时n-1次反射,n-2次反射形成的故推出斐波那契。 手动一些f1,f2,f3就OK#include #include #include #include #include #include #i... 阅读全文
posted @ 2014-09-17 18:17 Commence 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 题意:求计算fab[n]需要的计算次数MOD B 的结果首先容易知道的是f[n]=f[n-1]+f[n-2]+1;1.有 S(n)=F[n+2]-1; S[n]斐波那契数列前n项和。F[n+2]就第n+2项斐波那契数。证明就直接累加法:因为A=A+An所以An=A-A则A=A-AnA=An-A...... 阅读全文
posted @ 2014-09-17 11:11 Commence 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 转自http://www.cnblogs.com/vongang/archive/2012/04/01/2429015.html据说,矩阵快速幂在递推式优化上相当神奇,而且效率很高。。。 两矩阵相乘,朴素算法的复杂度是O(N^3)。如果求一次矩阵的M次幂,按朴素的写法就是O(N^3*M)。既然是求... 阅读全文
posted @ 2014-09-17 00:09 Commence 阅读(671) 评论(0) 推荐(0) 编辑
摘要: 来源UVA 10313整数i拆分成不超过j个整数的拆分方案数,是和整数i拆成若干个值不超过j的整数的拆分方案数是相同的原理Ferrers图像 详:http://blog.csdn.net/shiqi_614/article/details/7001949关于C++引用带的的不易发现的错误。来自于... 阅读全文
posted @ 2014-09-16 22:45 Commence 阅读(332) 评论(0) 推荐(0) 编辑