Competitive-Algos-and-Data-Structures
This repository includes the useful algorithims, data structures and concepts I encounter while doing competitive programming.
Points to Remember:
- Sum of product of all pairs of an array: ((a1 + a2 + ... + an)^2 - (a1^2 + a2^2 + ... + an^2)) / 2
- Sieve complexity: O(nlogn)
- Chicken McNugget Theorem/Frobenius Coin Theorem: If 'a' and 'b' are two co-prime numbers then: 1. Largest number that can not be expressed in the form ax+by is ab-a-b 2. Count of numbers that can not be expressed in the form ax+by are (a-1)(b-1)/2
- Taking ceil of large numbers in C++ : (a+b-1)/b