Concepts318

โš™๏ธAlgorithmAdvanced

Sqrt Decomposition on Queries

Sqrt decomposition on queries (time blocking) processes Q operations in blocks of size about \(\sqrt{Q}\) to balance per-query overhead and rebuild cost.

#sqrt decomposition#time blocking#query blocking+12
โˆ‘MathIntermediate

Linear Sieve

The linear sieve builds all primes up to n in O(n) time by ensuring each composite is marked exactly once by its smallest prime factor (SPF).

#linear sieve#smallest prime factor#spf+12
โˆ‘MathIntermediate

Prime Factorization

Prime factorization expresses any integer greater than 1 as a product of primes raised to powers, uniquely up to ordering.

#prime factorization#trial division#spf sieve+12
โˆ‘MathIntermediate

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).

#extended euclidean algorithm#bezout coefficients#gcd+12
โš™๏ธAlgorithmAdvanced

Polynomial Operations

Fast polynomial operations treat coefficients like numbers but use FFT/NTT to multiply in O(n \log n) time instead of O(n^2).

#polynomial#ntt#fft+12
โˆ‘MathIntermediate

Sieve of Eratosthenes

The Sieve of Eratosthenes marks multiples of each prime to find all primes up to n in O(n log log n) time.

#sieve of eratosthenes#segmented sieve#linear sieve+11
โˆ‘MathIntermediate

GCD and Euclidean Algorithm

The greatest common divisor (gcd) of two integers is the largest integer that divides both without a remainder.

#gcd#euclidean algorithm#extended euclidean+12
โš™๏ธAlgorithmAdvanced

Parallel Binary Search

Parallel Binary Search (PBS) lets you binary-search the answers of many queries at once by batching them by their current mid value.

#parallel binary search#offline queries#monotone predicate+10
โš™๏ธAlgorithmAdvanced

Convolution Applications

Convolution turns local pairwise combinations (like matching characters or adding two dice) into a single fast transformโ€“multiplyโ€“inverse pipeline.

#convolution#fft#ntt+12
โš™๏ธAlgorithmAdvanced

NTT (Number Theoretic Transform)

The Number Theoretic Transform (NTT) is an FFT-like algorithm that performs discrete convolutions exactly using modular arithmetic instead of floating-point numbers.

#ntt#number theoretic transform#polynomial multiplication+11
โš™๏ธAlgorithmIntermediate

Randomized Algorithms

Randomized algorithms use coin flips (random bits) to guide choices, often making code simpler and fast on average.

#randomized algorithms#las vegas#monte carlo+12
โš™๏ธAlgorithmAdvanced

FFT (Fast Fourier Transform)

FFT converts a polynomial from coefficients to values at the n-th roots of unity in O(n log n) time, enabling fast multiplication via pointwise products.

#fft#polynomial multiplication#convolution+11