matthewsamuel95 / ACM-ICPC-Algorithms

Algorithms used in Competitive Programming
2.07k stars 1.26k forks source link

Added Matrix Expo and Mo's Algorithm #1022

Open kushagra98 opened 4 years ago

kushagra98 commented 4 years ago

Matrix Exponentiation (also known as matrix power, repeated squaring) is a technique used to solve linear recurrences. This technique is very useful in competitive programming when dealing with linear recurrences (appears along Dynamic Programming).

Example to calculate the 10^18th fibonacci series term, it can not be done using Recursion, or DP but using matrix expo.

Mo's algorithm is one of the very popular range series algorithm.