定义数列: $\left\{\begin{eqnarray*} F_1 &=& A \\ F_2 &=& B \\ F_n &=& C\cdot{}F_{n-2}+D\cdot{}F_{n-1}+\left\lfloor\frac{P}{n}\right\rfloor \end{eqnarray*}\right.$ 求该数列的第n项. 很明显的整除分块问题,把$\left\lfloor\frac{P}{n}\right\rfloor$相同n的分为一组进行矩阵…
题意: 已知\(A,B,C,D,P,n\)以及 \[\left\{ \begin{aligned} & F_1 = A \\ & F_2 = B\\ & F_n = C*F_{n-2} + D*F_{n-2}+\lfloor(\frac{P}{n})\rfloor \end{aligned} \right. \] ,求\(F_n \ mod\ (1e9e+7)\),\(n \leq 1e9\) 思路: 显然\(\lfloor(\frac{P}{n})\rfloor\)相同的情况是有…
Sequence Problem Description Let us define a sequence as below f1=A f2=B fn=C*fn-2+D*fn-1+[p/n] Your job is simple, for each task, you should output Fn module 109+7.   Input The first line has only one integer T, indicates the number of tasks. Then,…
Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem Description \ \ \ \    Holion August will eat every thing he has found. \ \ \ \    Now there are many foods,but he does…
Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1731    Accepted Submission(s): 656 Problem Description Let us define a sequence as below F1=A F2=B Fn=C⋅Fn−2+D⋅Fn−1+⌊Pn⌋ Your job is s…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6395 因为题目数据范围太大,又存在递推关系,用矩阵快速幂来加快递推. 每一项递推时  加的下取整的数随着n变化,但因为下取整有连续性(n一段区间下取整的数是相同的),可以分块,相同的用矩阵快速幂加速 想了好久..如果最小的开始的值是[p/i]的数为i,那连续的一段长度是[p/(p/i)]-i+1,但为什么分段数是根号n级别啊?... 套矩阵快速幂,时间复杂度O(sqrt(n) * log(n)) ⎧…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud DNA Sequence Time Limit: 1000MS   Memory Limit: 65536K Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DN…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 其中a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY 最后的结果mod 1,000,000,007 n<=10^18. 分析:ai*bi=(ai-1 *ax+ay)*(bi-1 *bx+by) =(ai-1 * bi-1 *ax*bx)+(ai-1 *ax*by)+(bi-1 *bx*ay)+(ay*by) 设p=ax*bx,  q=ax*by, …
http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目已经给出, Ai*Bi=Ax*Bx*(Ai-1*Bi-1)+Ax*By*Ai-1+Bx*Ay*Bi-1+Ay*By AoD(n)=AoD(n-1)+AiBi 构造向量I{AoD(i-1),Ai*Bi,Ai,Bi,1} 初始向量为I0={0,A0*B0,A0,B0,1} 构造矩阵A{ 1,0,0,0,…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4990 题意 初始的ans = 0 给出 n, m for i in 1 -> n 如果 i 为奇数 ans = (ans * 2 + 1) % m 反之 ans = ans * 2 % m 思路 如果我们只计算 偶数项 那么递推公式就是 ans[n] = 4 * ans[n - 2] + 2 如果 n 是偶数 那么刚好 就按这个公式推 第 n / 2 项 如果 n 是奇数 那么就是 第 [ n /…