// Addition
(a + b) % m = ((a % m) + (b % m)) % m
// Subraction
(a - b) % m = ((a % m) - (b % m)) % m
// Multiplication
(a * b) % m = ((a % m) * (b % m)) % m
// Division (We need to use Mod Inverse)
(a / b) % m != ((a % m) / (b % m)) % m
// Using Fermat's Little theorem
// If m is prime
modInv(a, m) {
return fastpow(a, m - 2, m);
// pow(a, m - 2) % m
}
(a / b) % m = ((a % m) * modInv(b, m)) % m
- Merge Sort
- Inversion Count
- [Count Subarrays with Neg Sum]
- TASTYD (Subproblem)
- Tutorial (Hackerearth)
- Implementation
- DISHOWN
- ABC 120D
- Tutorial (Hackerearth)
- Implementation
- MAX-XOR
- SHKSTR
- ENGLISH
- Top 20 must do DP problems (GFG)
- Educational DP contest (AtCoder)
- EXPCAN
- Burst Balloons
- PEPPERA
- ABC 158F
- Tutorial (cp-algorithms)
- Tutorial
- Tutorial (Youtube)
- Implementation with Lazy Prop
- ABC 157E
- FLIPCOIN
- GSS1
- CYCLCSUM
- Tutorial (Codeforces)
- Tutorial (Don't worry too much about math behind it, learn how to use it)
- Codeforces 993E
- Learn Competitive Programming with CodeChef
- Colin Galen
- SecondThread
- Errichto
- Gaurav Sen
- William Lin
- Editorials on Codechef and Codeforces
- Book
- cp-algorithms
- Codeforces Tutorials
- Topcoder Tutorials