(矩阵)快速幂
请多指教^_^
这个作者很懒,什么都没留下…
展开
-
斐波那契数列(矩阵快速幂)
实现原理:这个,弱鸡的我不方便多说什么了~~,大佬比我讲的好的多啦。我只想写一下我的代码实现。大佬的博客代码:#include<iostream>#include<cstring>using namespace std;typedef long long ll;const ll mod = 1e9 + 7;class Fibonacci{public: ll a[2][2]; Fibonacci() { memset(a, 0, sizeof a); }原创 2020-05-22 17:21:39 · 189 阅读 · 0 评论 -
HDU 5363 Key Set
Problem Descriptionsoda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of S are key set...原创 2020-03-26 00:27:39 · 84 阅读 · 0 评论 -
普通快速幂
快速幂:这个其实是属于数学问题,我们在用计算机计算an 的时候一般是将n个a直接相乘,复杂度是O(n)。但是一旦遇到n较大的时候很容易TLE。故产生了快速幂算法,其时间复杂度为log2(n)。基本原理:原理是基于以下这两个公式:(1).x是奇数xn =(x2%mod)n/2%mod;(2)x是偶数xn =((x2%mod)n/2*x)%mod;实现代码:#include<iostream>using namespace std;typedef long long ll;原创 2020-05-22 16:39:53 · 154 阅读 · 0 评论 -
POJ:3070 Fibonacci
FibonacciTime Limit: 1000MS Memory Limit: 65536K Total Submissions:25754 Accepted: 17197DescriptionIn 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 Fibonaccisequence ar原创 2020-05-22 16:17:13 · 225 阅读 · 0 评论