diff --git a/src/algebra/big-integer.md b/src/algebra/big-integer.md index 27a0eba3d..d5cfbbf15 100644 --- a/src/algebra/big-integer.md +++ b/src/algebra/big-integer.md @@ -154,7 +154,7 @@ while (a.size() > 1 && a.back() == 0) The idea is to store the integer as its factorization, i.e. the powers of primes which divide it. -This approach is very easy to implement, and allows to do multiplication and division easily (assymptotically faster than the classical method), but not addition or subtraction. It is also very memory-efficient compared to the classical approach. +This approach is very easy to implement, and allows to do multiplication and division easily (asymptotically faster than the classical method), but not addition or subtraction. It is also very memory-efficient compared to the classical approach. This method is often used for calculations modulo non-prime number M; in this case a number is stored as powers of divisors of M which divide the number, plus the remainder modulo M. diff --git a/src/algebra/discrete-log.md b/src/algebra/discrete-log.md index aca171ae7..e697d065b 100644 --- a/src/algebra/discrete-log.md +++ b/src/algebra/discrete-log.md @@ -6,7 +6,7 @@ The discrete logarithm is an integer $x$ solving the equation $a^x \equiv b \pmod m$ -where $a$ and $m$ are relatively prime. (`Note`: if they are not relatively prime, then the algorithm described below is incorret, though it can be modified so that it can work). +where $a$ and $m$ are relatively prime. (`Note`: if they are not relatively prime, then the algorithm described below is incorrect, though it can be modified so that it can work). In this article, we describe the `Baby step - giant step` algorithm, proposed by Shanks in 1971, which has complexity $O(\sqrt{m} \log m)$. This algorithm is also known as `meet-in-the-middle`, because of it uses technique separation of tasks in half. @@ -30,7 +30,7 @@ Using the fact that $a$ and $m$ are relatively prime, we obtain: $a^{np} \equiv ba^q \pmod m$ -This new equation can be rewriten in a simplified form: +This new equation can be rewritten in a simplified form: $f_1(p) = f_2(q)$. diff --git a/src/algebra/euclid-algorithm.md b/src/algebra/euclid-algorithm.md index a9b4ac235..73f0de619 100644 --- a/src/algebra/euclid-algorithm.md +++ b/src/algebra/euclid-algorithm.md @@ -62,7 +62,7 @@ Let $d = \gcd(a, b)$. Then by definition $d\mid a$ and $d\mid b$. Now let's represent the remainder of the division of $a$ by $b$ as follows: $$a \bmod b = a - b \cdot \Bigl\lfloor\dfrac{a}{b}\Bigr\rfloor$$ -From this it follows that $d \mid (a \bmod b)$, which means we have the system of divisiblities: +From this it follows that $d \mid (a \bmod b)$, which means we have the system of divisibilities: $$\begin{cases}d \mid b,\\\\ d \mid (a \mod b)\end{cases}$$ Now we use the fact that for any three numbers $p$, $q$, $r$, if $p\mid q$ and $p\mid r$ then $p\mid \gcd(q, r)$. In our case, we get: diff --git a/src/algebra/fft.md b/src/algebra/fft.md index a30ca6bf1..f8e6f36bf 100644 --- a/src/algebra/fft.md +++ b/src/algebra/fft.md @@ -537,7 +537,7 @@ And since all the elements $a[i] = 0$ for $i \ge n$: $$c[k] = \sum_{i=0}^{n-1} a[i] b[k-i]$$ It is easy to see that this sum is just the scalar product of the vector $a$ with the $(k - (n - 1))$-th cyclic left shift of $b$. Thus these coefficients are the answer to the problem, and we were still able to obtain it in $O(n \log n)$ time. -Note here that $c[2n-1]$ also gives us the $n$-th cyclic shift but that is the same as the $0$-th cyclic shift so we don't need to consider that seperately into our answer. +Note here that $c[2n-1]$ also gives us the $n$-th cyclic shift but that is the same as the $0$-th cyclic shift so we don't need to consider that separately into our answer. ### Two stripes diff --git a/src/combinatorics/inclusion-exclusion.md b/src/combinatorics/inclusion-exclusion.md index c989591f2..bc9d759e7 100644 --- a/src/combinatorics/inclusion-exclusion.md +++ b/src/combinatorics/inclusion-exclusion.md @@ -83,7 +83,7 @@ Consider its generalization to calculate number of elements which are present in $$\left|\bigcup_{|B|=r}\left[\bigcap_{i \in B} A_i \cap \bigcap_{j \not\in B} \overline{A_j}\right]\right|=\sum_{m=r}^n (-1)^{m-r}\dbinom{m}{r} \sum_{|X|=m} \left|\bigcap_{i \in X} A_{i}\right|$$ -To proove this formula, consider some particular $B$. Due to basic inclusion-exclusion principle we can say about it that: +To prove this formula, consider some particular $B$. Due to basic inclusion-exclusion principle we can say about it that: $$\left|\bigcap_{i \in B} A_i \cap \bigcap_{j \not \in B} \overline{A_j}\right|=\sum_{m=r}^{n} (-1)^{m-r} \sum_{\substack{|X|=m \newline B \subset X}}\left|\bigcap_{i\in X} A_{i}\right|$$ @@ -228,7 +228,7 @@ Notice first that we can easily count the number of strings that satisfy at once Learn now to solve the first version of the problem: when the string must satisfy exactly $k$ of the patterns. -To solve it, iterate and fix a specific subset $X$ from the set of patterns consisting of $k$ patterns. Then we have to count the number of strings that satisfy this set of patterns, and only matches it, that is, they don't match any other pattern. We will use the inclusion-exclusion principle in a slightly different manner: we sum on all supersets $Y$ (subsets from the original set of strings that cointain $X$), and either add to the current answer of subtract it from the number of strings: +To solve it, iterate and fix a specific subset $X$ from the set of patterns consisting of $k$ patterns. Then we have to count the number of strings that satisfy this set of patterns, and only matches it, that is, they don't match any other pattern. We will use the inclusion-exclusion principle in a slightly different manner: we sum on all supersets $Y$ (subsets from the original set of strings that contain $X$), and either add to the current answer of subtract it from the number of strings: $$ ans(X) = \sum_{Y \supseteq X} (-1)^{|Y|-k} \cdot f(Y) $$