🐐
LeetGoat
Interview Prep
Competitive Programming
Discord
Matrix templates
Range queries
2D range queries
Sets
Union find
Strings
Tree queries
Tree helpers
Graphs
Matrices
Math
Primes
Bit ops & Bitset
Geometry
Misc.
Golden References
Matrices
matMul(A, B, mod) O(x·y·z)
A[x, y] @ B[y, z] = C[x, z], mod mod: C[i][j] = row i of A times column j of B
vecMatMul(vec, M, mod) O(x·y)
vec[1, x] @ M[x, y] = res[1, y], mod mod: res[j] = vec times column j of M
matPow(M, p, mod) O(x³·log p)
M[x, x] ^ p, mod mod (p = 0 gives the identity)