Skip to content

Commit 921fc8a

Browse files
committed
formatting of CRT
1 parent 29b42e8 commit 921fc8a

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/algebra/chinese-remainder-theorem.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ The Chinese Remainder Theorem (which will be referred to as CRT in the rest of t
1313
Let $m = m_1 \cdot m_2 \cdots m_k$, where $m_i$ are pairwise coprime. In addition to $m_i$, we are also given a set of congruence equations
1414

1515
$$\begin{align}
16-
a &\equiv a_1 \pmod{m_1} \\\\
17-
a &\equiv a_2 \pmod{m_2} \\\\
18-
&\ldots \\\\
16+
a &\equiv a_1 \pmod{m_1} \\
17+
a &\equiv a_2 \pmod{m_2} \\
18+
&\ldots \\
1919
a &\equiv a_k \pmod{m_k}
2020
\end{align}$$
2121

@@ -30,8 +30,8 @@ $$x \equiv a \pmod{m}$$
3030
is equivalent to the system of equations
3131

3232
$$\begin{align}
33-
x &\equiv a_1 \pmod{m_1} \\\\
34-
&\ldots \\\\
33+
x &\equiv a_1 \pmod{m_1} \\
34+
&\ldots \\
3535
x &\equiv a_k \pmod{m_k}
3636
\end{align}$$
3737

@@ -63,8 +63,8 @@ $$a_2 \equiv x_1 + x_2 p_1 \pmod{p_2}.$$
6363
which can be rewritten by subtracting $x_1$ and dividing by $p_1$ to get
6464

6565
$$\begin{array}{rclr}
66-
a_2 - x_1 &\equiv& x_2 p_1 &\pmod{p_2} \\\\
67-
(a_2 - x_1) r_{12} &\equiv& x_2 &\pmod{p_2} \\\\
66+
a_2 - x_1 &\equiv& x_2 p_1 &\pmod{p_2} \\
67+
(a_2 - x_1) r_{12} &\equiv& x_2 &\pmod{p_2} \\
6868
x_2 &\equiv& (a_2 - x_1) r_{12} &\pmod{p_2}
6969
\end{array}$$
7070

@@ -184,5 +184,7 @@ class Number {
184184
* Modular scheme itself does not allow representing negative numbers. However, it can be seen that if we know that the absolute values our numbers are smaller than $p / 2$, then we know that it must be negative when the resulting number is greater than $p / 2$. The flag `can_be_negative` in this code allows converting it to negative in this case.
185185

186186
## Practice Problems:
187+
188+
* [Google Code Jam - Golf Gophers](https://codingcompetitions.withgoogle.com/codejam/round/0000000000051635/0000000000104f1a#problem)
187189
* [Hackerrank - Number of sequences](https://www.hackerrank.com/contests/w22/challenges/number-of-sequences)
188190
* [Codeforces - Remainders Game](http://codeforces.com/problemset/problem/687/B)

0 commit comments

Comments
 (0)