还好$QwQ$ 思路:矩阵快速幂 提交:1次 题解: 如图: 注意$n,m$如果小于$k$就不要快速幂了,直接算就行... #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #define ull unsigned long long #define ll long long #define R register ll using namespace std;…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3231 矩阵乘法裸题. 1018是10^18.别忘了开long long. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace std; ; int n; ll L,R,b[N],c[N…
矩阵乘法裸题..差分一下然后用矩阵乘法+快速幂就可以了. --------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 20; typedef long long ll; t…
/* 矩阵乘法+快速幂. 一开始迷之题意.. 这个gcd有个规律. a b b c=a*x+b(x为常数). 然后要使b+c最小的话. 那x就等于1咯. 那么问题转化为求 a b b a+b 就是斐波那契了.... */ #include<iostream> #include<cstdio> #define MAXN 3 #define LL long long #define mod 1000000007 using namespace std; LL n; LL a[MAXN]…