题目传送门 /* 矩阵快速幂:求第n项的Fibonacci数,转置矩阵都给出,套个模板就可以了.效率很高啊 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; ; struct Mat { ][]; }; Mat multi_mod(Mat a, Mat…
题意:给你一个n,输出Fibonacci (n)%10000的结果 思路:裸矩阵快速幂乘,直接套模板 代码: #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; ,M=,P=; ; struct Matrix { ll m[N][N]; }; Matrix A={,, ,}; Matrix I={,, ,}; Matrix…
Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … An alternative formula for the Fibonacci sequence is…
<题目链接> Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … An alternative formula for the Fibonacci seq…
Fibonacci Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18607   Accepted: 12920 Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequen…
题目 还是一道基础的矩阵快速幂. 具体的居者的幂公式我就不明示了. #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ; struct matrix { ][]; }; matrix multiply(matrix x,matrix y)//矩阵乘法 { matrix temp; ;i<num;i++) { ;j<num;j++) { ; ;k<n…
题目链接 题意 : 用矩阵相乘求斐波那契数的后四位. 思路 :基本上纯矩阵快速幂. #include <iostream> #include <cstring> #include <cstdio> using namespace std; struct Matrix { ][]; }; int n; Matrix matrix_mul(Matrix a,Matrix b) { Matrix c; ; i < ; i++) { ; j < ; j++) { c…
题意: 求出斐波那契数列的第n项的后四位数字 思路:f[n]=f[n-1]+f[n-2]递推可得二阶行列式,求第n项则是这个矩阵的n次幂,所以有矩阵快速幂模板,二阶行列式相乘, sum[ i ] [ j ]+=v[i][k]*u[k][j] ___k==1->j: 模板: #include<stdio.h> #include<map> using namespace std; //矩阵快速幂 struct node { int m[10][10]; }a,b; node ju…
poj 3070 && nyoj 148 矩阵快速幂 题目链接 poj: http://poj.org/problem?id=3070 nyoj: http://acm.nyist.net/JudgeOnline/problem.php?pid=148 思路: 矩阵快速幂 直接求取 代码: #include <iostream> #include <string.h> #include <math.h> #include <stdio.h>…
矩阵快速幂:http://www.cnblogs.com/atmacmer/p/5184736.html 题目链接 #include<iostream> #include<cstdio> using namespace std; typedef long long ll; #define MOD 10000 ll a[],b[],a0[],b0[]; void pow_mod(ll n) { a0[]=a0[]=a0[]=,a0[]=; b0[]=b0[]=,b0[]=b0[]=;…