HDU - 1588 矩阵前缀和】的更多相关文章

题意:给定\(k,b,n,m\),求\(\sum_{i=0}^{n-1}f(g(i))\) 其中\(f(i)=f(i-1)+f(i-2),f(1)=1,f(0)=0\),\(g(i)=k*i+b\) 令矩阵\(A\)为 \[ \begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix} \] 那么 \[ \begin{bmatrix} f(n+1) \\ f(n) \\ \end{bmatrix}=A^n \begin{bmatrix} 1 \\ 0 \\…
Gauss Fibonacci Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3149    Accepted Submission(s): 1323 Problem Description Without expecting, Angel replied quickly.She says: "I'v heard that you'r…
这个题目搞了我差不多一个下午,之前自己推出一个公式,即 f[n+k]=k*f[n]+f[n-1]结果发现根本不能用,无法降低复杂度. 后来又个博客的做法相当叼,就按他的做法来了 即 最终求得是 S(n)=f[b]+f[b+k]+f[b+2*k]....f[b+n*k] (原题的意思好像是不用加到第n项,但实测确实要加到该项) 然后我们令 A={1,1}(标准的斐波那契矩阵) {1,0}发现 f[b]=A^b,f[b+k]=A^(b+k),....f[b+nk]=A^(b+nk); 提取公共因子…
HDU 1588 Gauss Fibonacci(矩阵高速幂+二分等比序列求和) ACM 题目地址:HDU 1588 Gauss Fibonacci 题意:  g(i)=k*i+b;i为变量.  给出k,b,n,M,问( f(g(0)) + f(g(1)) + ... + f(g(n)) ) % M的值. 分析:  把斐波那契的矩阵带进去,会发现这个是个等比序列. 推倒: S(g(i)) = F(b) + F(b+k) + F(b+2k) + .... + F(b+nk) // 设 A = {1…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5151You have a rectangle of size N × M, N rows from top to bottom and M columns from left to right,that is divided int…
http://acm.hdu.edu.cn/showproblem.php?pid=4291 凡是取模的都有循环节-----常数有,矩阵也有,并且矩阵的更奇妙: g(g(g(n))) mod 109 + 7  最外层MOD=1e9+7  能够算出g(g(n))的循环节222222224.进而算出g(n)的循环节183120LL.然后由内而外计算就可以 凝视掉的是求循环节的代码 //#pragma comment(linker, "/STACK:102400000,102400000")…
Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1384    Accepted Submission(s): 630 Problem Description Kazari has an array A length of L, she plans to generate a…
题目的大意就是求等差数列对应的Fibonacci数值的和,容易知道Fibonacci对应的矩阵为[1,1,1,0],因为题目中f[0]=0,f[1]=1,所以推出最后结果f[n]=(A^n-1).a,所以 f(g(i))= f(k*i+b)= (A^(k*i+b-1)).a,i从 0取到 n-1,取出公因式 A^(b-1)(因为矩阵满足分配率),然后所求结果可化为 A^(b-1) * (A^0 + A^k + A^2k +....+ A^(n-1)k),化到这里后难点就是求和了,一开始我尝试暴力…
Description Without expecting, Angel replied quickly.She says: "I'v heard that you'r a very clever boy. So if you wanna me be your GF, you should solve the problem called GF~. " How good an opportunity that Gardon can not give up! The "Prob…
g(i)=k*i+b; 0<=i<nf(0)=0f(1)=1f(n)=f(n-1)+f(n-2) (n>=2)求f(b) +f(k+b) +f(2*k+b) +f((n-1)*k +b) 之和 Sample Input2 1 4 100 // k b n MOD2 0 4 100 Sample Output2112 矩阵A      相当于 1 1          f(2)  f(1) 1 0          f(1)  f(0) | 1       1| ^b          |…