http://acm.hdu.edu.cn/showproblem.php?pid=2855 化简这个公式,多写出几组就会发现规律 d[n]=F[2*n] 后面的任务就是矩阵快速幂拍一个斐波那契模板出来了 这里用的是2维 vector #include<iostream> #include<cstdio> #include<vector> using namespace std; typedef vector<int>vec; typedef vector&…
http://acm.hdu.edu.cn/showproblem.php?pid=5950 题意:给出 a,b,n,递推出 f(n) = f(n-1) + f(n-2) * 2 + n ^ 4. f(1) = a, f(2) = b. 思路:在比赛时候知道是矩阵快速幂,可是推不出矩阵.那个n^4不知道怎么解决.结束后问其他人才知道要构造一个7 * 7的矩阵,而不是3 * 3的.. 转自:http://blog.csdn.net/spring371327/article/details/5297…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=3292 No more tricks, Mr Nanguo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 587    Accepted Submission(s): 400 Problem Description Now Sailormoon…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4965 题意 给出两个矩阵 一个A: n * k 一个B: k * n C = A * B M = (A * B) ^ (n * n) 然后将M中所有的元素对6取余后求和 思路 矩阵结合律.. M = (A * B) * (A * B) * (A * B) * (A * B) * (A * B) * (A * B) * (A * B) * (A * B) -- 其实也等价于 M = A * (B *…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4565 题目大意: 给出a,b,n,m,求出的值, 解题思路: 因为题目中出现了开根号,和向上取整后求余,所以用矩阵快速幂加速求解过程的时候,会产生误差,就很自然地想到了凑数,因为(a-1)^2<b<a^2,得出0<a-sqrt(b)<1,则无论n取多大,(a-sqrt(b))^n都是小于1的,(a-sqrt(b))^n 与 (a+sqrt(b))^n共轭,两者展开后会相互抵销,所以(…
题目要求求出(√2+√3)2n的整数部分再mod 1024. (√2+√3)2n=(5+2√6)n 如果直接计算,用double存值,当n很大的时候,精度损失会变大,无法得到想要的结果. 我们发现(5+2√6)n+(5-2√6)n是一个整数(2√6的偶数次幂总会正负抵消掉),并且(5-2√6)n是小于1的.所以我们就只需要求出Sn-1即可.令 An=(5+2√6)n;  Bn=(5-2√6)n. Sn=An+Bn     Sn为整数. Sn*((5+2√6)+(5-2√6))=Sn*10 Sn*…
题意:略 简单的矩阵快速幂就行了 #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define LL long long #define N 10 int m; struct node{ int mat[N][N]; node operator *(const node &x){ node tmp; memset(tmp.mat,0,sizeof(tmp…
GTY's birthday gift Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)  [Problem Description] FFZ's birthday is coming. GTY wants to give a gift to ZZF. He asked his gay friends what he should give to ZZF. One of them…
题目 A Simple Math Problem 解析 矩阵快速幂模板题 构造矩阵 \[\begin{bmatrix}a_0&a_1&a_2&a_3&a_4&a_5&a_6&a_7&a_8&a_9\\ 1&0&0&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0&0&0\\ 0&…
Queuing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6639    Accepted Submission(s): 2913 Problem Description Queues and Priority Queues are data structures which are known to most computer…