题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1113 题意:中文题诶- 思路:矩阵快速幂模板 代码: #include <iostream> #define ll long long using namespace std; ; ; int n, m; typedef struct node{ ll x[MAXN][MAXN]; }matrix; matrix matrix_multi(matrix a,…
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…
题目分析: 对于给出的n,求出斐波那契数列第n项的最后4为数,当n很大的时候,普通的递推会超时,这里介绍用矩阵快速幂解决当递推次数很大时的结果,这里矩阵已经给出,直接计算即可 #include<iostream> #include<stdio.h> using namespace std; ; struct mat{ ][]; }; mat operator * (mat a, mat b){ //重载乘号,同时将数据mod10000 mat ret; ; i < ; i++…