Another kind of Fibonacci Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1219    Accepted Submission(s): 466 Problem Description As we all known , the Fibonacci series : F(0) = 1, F(1) = 1, F(N…
Another kind of Fibonacci                                                        Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)                                                                                   Tot…
题目链接 构造矩阵 看的题解,剩下的就是模板了,好久没写过了,注意取余. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; #define MOD 10007 #defin…
Another kind of Fibonacci [题目链接]Another kind of Fibonacci [题目类型]矩阵+ll超时必须用int&输入必须取模&M必须是int类型 &题解: 算出矩阵的每一行一定要和初始化的那个矩阵不一样,如果有一项是一样的,那么就推不出最后的答案,所以矩阵如下: 代码还有问题,T了,不知道为什么,明天在看吧 [时间复杂度]\(O(logn)\) &超时代码: #include <cstdio> #include <…
参考了某大佬的 我们可以根据(s[n-2], a[n-1]^2, a[n-1]*a[n-2], a[n-2]^2) * A = (s[n-1], a[n]^2, a[n]*a[n-1], a[n-1]^2) 能够求出关系矩阵 |1     0      0     0 |A =   |1   x^2    x     1 |        |0  2*x*y  y     0 |        |0   y^2    0     0 | 这样就A了! #include <iostream> #…
题意:有一个递推式f(x) 当 x < 10    f(x) = x.当 x >= 10  f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10) 同时ai(0<=i<=9) 不是 0 就是 1: 现在给你 ai 的数字,以及k和mod,请你算出 f(x)%mod 的结果是多少 思路:线性递推关系是组合计数中常用的一种递推关系,如果直接利用递推式,需要很长的时间才能计算得出,时间无法承受,但是现在我们已知…
给你 A(0) = 1 , A(1) = 1 , A(N) = X * A(N - 1) + Y * A(N - 2) (N >= 2). 求 S(N) = A(0) 2 +A(1) 2+……+A(n) 2. 由于线性代数只能做线性变换,故要得出 A(n) 2 的递推式 A(n) 2  =X2A(N-1)2+Y2A(N-2)2+2XYA(N-1)A(N-2); 难点就在于 A(N-1)A(N-2) 这一项 故找到此项递推式 A(N-1)A(N-2) = (XA(N-2)+YA(N-3))*A(N…
http://acm.hdu.edu.cn/showproblem.php?pid=5015 由于是个二维的递推式,当时没有想到能够这样构造矩阵.从列上看,当前这一列都是由前一列递推得到.依据这一点来构造矩阵.令b[i]代表第i列,是一个(n+2)*1的矩阵,即b[1] = [1,233......],之所以在加了两行,是要从前一个矩阵b[i-1]得到b[i]中的第二个数2333...,再构造一个转换矩阵a,它是一个(n+2)*(n+2)的矩阵,那么a^(m-1) * b就是第m列. /* a矩…
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…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6621    Accepted Submission(s): 4071 Problem Description Lele now is thin…