Concepts10
Overflow Prevention Techniques
Integer overflow happens when a computed value exceeds the range of its type; in C++ this silently wraps for unsigned and is undefined for signed, so prevention is crucial.
Linear Diophantine Equations
A linear Diophantine equation ax + by = c has integer solutions if and only if gcd(a, b) divides c.
Euler's Totient Function
Euler's Totient Function φ(n) counts how many integers from 1 to n are coprime with n.
Modular Arithmetic Basics
Modular arithmetic is arithmetic with wrap-around at a fixed modulus m, like numbers on a clock.
Modular Inverse
A modular inverse of a modulo m is a number a_inv such that a × a_inv ≡ 1 (mod m).
Chinese Remainder Theorem
The Chinese Remainder Theorem (CRT) reconstructs an integer from its remainders modulo pairwise coprime moduli and guarantees a unique answer modulo the product.
Prime Factorization
Prime factorization expresses any integer greater than 1 as a product of primes raised to powers, uniquely up to ordering.
Extended Euclidean Algorithm
The Extended Euclidean Algorithm finds integers x and y such that ax + by = gcd(a, b) while also computing gcd(a, b).
GCD and Euclidean Algorithm
The greatest common divisor (gcd) of two integers is the largest integer that divides both without a remainder.
Sparse Table
A Sparse Table is a static range-query data structure that preprocesses an array in O(n \log n) time and answers many queries in O(1) time.