![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
算法模板小抄
算法模板
鱼儿冒个泡
这个作者很懒,什么都没留下…
展开
-
矩阵快速幂
typedef long long ll; const int mod = 1000007; int n,k; //n阶方阵(假设n<=10,N可以随之调整),幂次为k struct Matrix { static const int N = 15; ll a[N][N]; Matrix(ll e = 0) { for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) a[i][j] = e * (i =原创 2021-04-07 00:07:50 · 50 阅读 · 0 评论 -
基础数论
//最大公约数 int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } //扩展欧几里得算法 int extgcd(int a, int b, int& x, int& y) { int d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; }原创 2021-04-01 20:57:33 · 55 阅读 · 0 评论