题目分析: 对于给出的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++…
Fibonacci Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9630 Accepted: 6839 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…
题目链接:http://codeforces.com/problemset/problem/316/E3 题意:一个数列A三种操作:(1)1 x y将x位置的数字修改为y:(2)2 x y求[x,y]区间的数字的和,和函数为如下:(3)3 x y z将[x,y]区间的数字统一加z. 思路:很明显,这是一个线段树的题目.其中第一种和第三种操作都很容易搞定,第一种直接更新到底:第三种增加标记.显然为了求和,我们必须要在节点上增加一个和,表示以这个节点为根的子树的数字的和函数,这里我们用a来表示.那么…