![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
矩阵快速幂
WA怪
这个作者很懒,什么都没留下…
展开
-
Arc of Dream
Arc of DreamTime Limit: 2000/2000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 7124Accepted Submission(s): 2232Problem DescriptionAn Arc of Dream is a curve defined by following function:wherea0= A0ai...原创 2020-07-18 18:16:34 · 197 阅读 · 0 评论 -
M斐波那契数列
M斐波那契数列Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 7570Accepted Submission(s): 2261Problem DescriptionM斐波那契数列F[n]是一种整数数列,它的定义如下:F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 )...原创 2020-07-17 19:09:50 · 144 阅读 · 2 评论 -
How Many Calls?
How Many Calls?(点击此链接即可看题面)题意:f(0) = 0, f(1) = 1, f(n) = f(n-1) + f(n-2),问求f(n)时,调用了这个递推关系式几次?思路:假设F(n-1)需要用到递推式a次,F(n-2)需要用到递推式b次,那么F(n)需要用到递推式的次数应该为a+b+1,因为他首先对F(n) = F(n-1) + F(n-2)递推(用了一次),然后再对F(n-1)递推(用了a次),再对F(n-2)递推(用了b次)下面根据F(n) = F(n-1) +原创 2020-07-17 18:34:38 · 168 阅读 · 0 评论 -
Recurrences
Recurrences思路:f(n)f(n-1)…f(n-d+1)= f(n-1)f(n-2)…f(n-d)a1100a2010a3001⋯000⋮⋱⋮ ad000⋯0以下是ac代码:#include <iostream>#include<cstdio>#include<cstring>using namespace std;typedef long long ll;struct matrix{ ll x[100][1...原创 2020-07-16 19:42:00 · 103 阅读 · 0 评论 -
So Easy! hdu4565
So Easy!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7287Accepted Submission(s): 2429Problem Description A sequence Snis defined as:Where a, b, n, m are positive integers.┌x┐is th...转载 2020-07-16 19:26:25 · 111 阅读 · 0 评论 -
矩阵快速幂 递推矩阵小结
做了几道矩阵快速幂的题目,参考了wust_wenhao,qdu_zhaiH的博文,加上自己的一些理解,整理了一些例子。斐波那契数列:f(n) = f(n-1) + f(n-2) (n >= 2)二次函数:f(n) = a * f(n-1) + b * f(n-2) + c幂次:f(n) = a * f(n-1) + bn平方f(n) = a * f(n - 1) + n2立方f(n) = a * f(n-1) + n3数列:f(n) = A + A2 + A3 + …转载 2020-07-15 19:44:28 · 124 阅读 · 0 评论 -
Power of Matrix
题目描述大致题意:给你一个矩阵A,以及n,计算出矩阵A+A2+A3… + Ak,由于数很大,因此只保留最后一位数,每个样例之间需要打印空行。思路:这个题跟求斐波那契数列的第k项有点不一样,但是其实又是一样的,只不过 斐波那契数列第几项是一个数,而这里是个矩阵。难免难点就在于如何构造:由题意可知,f(k) = A*f(k-1) + A,我们可以根据这个条件构造地推矩阵。具体一点就是以下是ac代码:#include <iostream>#include<cstdio>原创 2020-07-15 16:30:24 · 192 阅读 · 0 评论 -
Reading comprehension
Reading comprehensionRead the program below carefully then answer the question.#pragma comment(linker, “/STACK:1024000000,1024000000”)#include #include#include #include #include #includeconst int MAX=100000*2;const int INF=1e9;int main(){int n原创 2020-07-14 20:45:46 · 261 阅读 · 0 评论 -
Jzzhu and Sequences
Jzzhu has invented a kind of sequences, they meet the following property:f1 = x, f2 = y, when i>=2 , fi = fi-1 + fi+1You are given x and y, please calculate f n modulo 1000000007 (109 + 7).InputThe first line contains two integers x and y (|x|, |y|原创 2020-07-14 20:34:37 · 153 阅读 · 0 评论