hdu 5950 Recursive sequence】的更多相关文章

Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 249    Accepted Submission(s): 140 Problem Description Farmer John likes to play mathematics games with his N cows. Recently, t…
Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn,…
题目链接:Recursive sequence 题意:给出前两项和递推式,求第n项的值. 题解:递推式为:$F[i]=F[i-1]+2*f[i-2]+i^4$ 主要问题是$i^4$处理,容易想到用矩阵快速幂,那么$i^4$就需要从$(i-1)$转移过来. $ i^4 = (i-1)^4 + 4*(i-1)^3 + 6*(i-1)^2 + 4*(i-1) + 1$ $f_i$ $f_{i-1}$ $i^4$ $i^3$ $i^2$ $i$ $1$ = $f_{i-1}$ $f_{i-2}$ $(i…
Recursive sequence Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stand in a line, while John writes two positive numbers a and b on a blackboard. And the…
Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2882    Accepted Submission(s): 1284 Problem Description Farmer John likes to play mathematics games with his N cows. Recently,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stand in a line, while John writes two positive numbers…
思路:一开始不会n^4的推导,原来是要找n和n-1的关系,这道题的MOD是long long 的,矩阵具体如下所示 最近自己总是很坑啊,代码都瞎吉坝写,一个long long的输入写成%d一直判我TLE,一度怀疑矩阵快速幂地复杂度orz 代码: #include<set> #include<cstring> #include<cstdio> #include<algorithm> #define ll long long const int maxn = 7…
题目链接 题意 给定\(c_0,c_1,求c_n(c_0,c_1,n\lt 2^{31})\),递推公式为 \[c_i=c_{i-1}+2c_{i-2}+i^4\] 思路 参考 将递推式改写\[\begin{pmatrix}f(n)\\f(n-1)\\n^4\\n^3\\n^2\\n\\1\end{pmatrix}=\begin{pmatrix}1&2&1&4&6&4&1\\1&0&0&0&0&0&0\\0&a…
题意:告诉你数列的递推公式为f(n+1)=f(n)+2*f(n-1)+(n+1)^4 以及前两项a,b:问第n项为多少,结果对2147493647取模. 题解:有递推公式,马上应该就能想到矩阵快速幂:但是,以前写过的矩阵快速幂绝大都是常数做系数的,如果这题是f(n+1)=f(n)+2*f(n-1)这样那倒蛮简单的构造个2*2矩阵很快能做出来:而后面接个(n+1)^4这种当时就gg了,,不知该如何下手.后来拜读了大佬的代码后才恍然大悟,,=_=... 对于(n+1)^4,展开来后就是n^4+4*n…
题意:递推公式 Fn = Fn-1 + 2 * Fn-2 + n*n,让求 Fn; 析:很明显的矩阵快速幂,因为这个很像Fibonacci数列,所以我们考虑是矩阵,然后我们进行推公式,因为这样我们是无法进行运算的.好像有的思路,最后也没想出来,还是参考的大牛的博客 http://blog.csdn.net/spring371327/article/details/52973534 那是讲的很详细了,就不多说了,注意这个取模不是1e9+7,一开始忘了.. 代码如下: #pragma comment…