-
Notifications
You must be signed in to change notification settings - Fork 0
/
kactl.patch
509 lines (488 loc) · 21 KB
/
kactl.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
diff --git a/content/combinatorial/chapter.tex b/content/combinatorial/chapter.tex
index 686a119..f2c2ed3 100644
--- a/content/combinatorial/chapter.tex
+++ b/content/combinatorial/chapter.tex
@@ -1,101 +1,5 @@
\chapter{Combinatorial}
-\section{Permutations}
- \subsection{Factorial}
- \import{factorial.tex}
- \kactlimport{IntPerm.h}
-
- \subsection{Cycles}
- Let $g_S(n)$ be the number of $n$-permutations whose cycle lengths all belong to the set $S$. Then
- $$\sum_{n=0} ^\infty g_S(n) \frac{x^n}{n!} = \exp\left(\sum_{n\in S} \frac{x^n} {n} \right)$$
-
- \subsection{Derangements}
- Permutations of a set such that none of the elements appear in their original position.
- \[ \mkern-2mu D(n) = (n-1)(D(n-1)+D(n-2)) = n D(n-1)+(-1)^n = \left\lfloor\frac{n!}{e}\right\rceil \]
-
- \subsection{Burnside's lemma}
- Given a group $G$ of symmetries and a set $X$, the number of elements of $X$ \emph{up to symmetry} equals
- \[ {\frac {1}{|G|}}\sum _{{g\in G}}|X^{g}|, \]
- where $X^{g}$ are the elements fixed by $g$ ($g.x = x$).
-
- If $f(n)$ counts ``configurations'' (of some sort) of length $n$, we can ignore rotational symmetry using $G = \mathbb Z_n$ to get
- \[ g(n) = \frac 1 n \sum_{k=0}^{n-1}{f(\text{gcd}(n, k))} = \frac 1 n \sum_{k|n}{f(k)\phi(n/k)}. \]
-
\section{Partitions and subsets}
- \subsection{Partition function}
- Number of ways of writing $n$ as a sum of positive integers, disregarding the order of the summands.
- \[ p(0) = 1,\ p(n) = \sum_{k \in \mathbb Z \setminus \{0\}}{(-1)^{k+1} p(n - k(3k-1) / 2)} \]
- \[ p(n) \sim 0.145 / n \cdot \exp(2.56 \sqrt{n}) \]
-
- \begin{center}
- \begin{tabular}{c|c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c@{\ }c}
- $n$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 20 & 50 & 100 \\ \hline
- $p(n)$ & 1 & 1 & 2 & 3 & 5 & 7 & 11 & 15 & 22 & 30 & 627 & $\mathtt{\sim}$2e5 & $\mathtt{\sim}$2e8 \\
- \end{tabular}
- \end{center}
-
- \subsection{Lucas' Theorem}
- Let $n,m$ be non-negative integers and $p$ a prime. Write $n=n_kp^k+...+n_1p+n_0$ and $m=m_kp^k+...+m_1p+m_0$. Then $\binom{n}{m} \equiv \prod_{i=0}^k\binom{n_i}{m_i} \pmod{p}$.
-
\subsection{Binomials}
\kactlimport{multinomial.h}
-
-\section{General purpose numbers}
- \subsection{Bernoulli numbers}
- EGF of Bernoulli numbers is $B(t)=\frac{t}{e^t-1}$ (FFT-able).
- $B[0,\ldots] = [1, -\frac{1}{2}, \frac{1}{6}, 0, -\frac{1}{30}, 0, \frac{1}{42}, \ldots]$
-
- Sums of powers:
- \small
- \[ \sum_{i=1}^n n^m = \frac{1}{m+1} \sum_{k=0}^m \binom{m+1}{k} B_k \cdot (n+1)^{m+1-k} \]
- \normalsize
-
- Euler-Maclaurin formula for infinite sums:
- \small
- \[ \sum_{i=m}^{\infty} f(i) = \int_m^\infty f(x) dx - \sum_{k=1}^\infty \frac{B_k}{k!}f^{(k-1)}(m) \]
- \[ \approx \int_{m}^\infty f(x)dx + \frac{f(m)}{2} - \frac{f'(m)}{12} + \frac{f'''(m)}{720} + O(f^{(5)}(m)) \]
- \normalsize
-
- \subsection{Stirling numbers of the first kind}
- Number of permutations on $n$ items with $k$ cycles.
- \begin{align*}
- &c(n,k) = c(n-1,k-1) + (n-1) c(n-1,k),\ c(0,0) = 1 \\
- &\textstyle \sum_{k=0}^n c(n,k)x^k = x(x+1) \dots (x+n-1)
- \end{align*}
- $c(8,k) = 8, 0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1$ \\
- $c(n,2) = 0, 0, 1, 3, 11, 50, 274, 1764, 13068, 109584, \dots$
-
- \subsection{Eulerian numbers}
- Number of permutations $\pi \in S_n$ in which exactly $k$ elements are greater than the previous element. $k$ $j$:s s.t. $\pi(j)>\pi(j+1)$, $k+1$ $j$:s s.t. $\pi(j)\geq j$, $k$ $j$:s s.t. $\pi(j)>j$.
- $$E(n,k) = (n-k)E(n-1,k-1) + (k+1)E(n-1,k)$$
- $$E(n,0) = E(n,n-1) = 1$$
- $$E(n,k) = \sum_{j=0}^k(-1)^j\binom{n+1}{j}(k+1-j)^n$$
-
- \subsection{Stirling numbers of the second kind}
- Partitions of $n$ distinct elements into exactly $k$ groups.
- $$S(n,k) = S(n-1,k-1) + k S(n-1,k)$$
- $$S(n,1) = S(n,n) = 1$$
- $$S(n,k) = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}j^n$$
-
- \subsection{Bell numbers}
- Total number of partitions of $n$ distinct elements. $B(n) =$
- $1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, \dots$. For $p$ prime,
- \[ B(p^m+n)\equiv mB(n)+B(n+1) \pmod{p} \]
-
- \subsection{Labeled unrooted trees}
- \# on $n$ vertices: $n^{n-2}$ \\
- \# on $k$ existing trees of size $n_i$: $n_1n_2\cdots n_k n^{k-2}$ \\
- \# with degrees $d_i$: $(n-2)! / ((d_1-1)! \cdots (d_n-1)!)$
-
- \subsection{Catalan numbers}
- \[ C_n=\frac{1}{n+1}\binom{2n}{n}= \binom{2n}{n}-\binom{2n}{n+1} = \frac{(2n)!}{(n+1)!n!} \]
- \[ C_0=1,\ C_{n+1} = \frac{2(2n+1)}{n+2}C_n,\ C_{n+1}=\sum C_iC_{n-i} \]
- ${C_n = 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, \dots}$
- \begin{itemize}[noitemsep]
- \item sub-diagonal monotone paths in an $n\times n$ grid.
- \item strings with $n$ pairs of parenthesis, correctly nested.
- \item binary trees with with $n+1$ leaves (0 or 2 children).
- \item ordered trees with $n+1$ vertices.
- \item ways a convex polygon with $n+2$ sides can be cut into triangles by connecting vertices with straight lines.
- \item permutations of $[n]$ with no 3-term increasing subseq.
- \end{itemize}
diff --git a/content/contest/chapter.tex b/content/contest/chapter.tex
index 8c95e1a..ae51693 100644
--- a/content/contest/chapter.tex
+++ b/content/contest/chapter.tex
@@ -1,7 +1,3 @@
\chapter{Contest}
\kactlimport[-l rawcpp]{template.cpp}
-\kactlimport[-l sh]{.bashrc}
-\kactlimport[-l raw]{.vimrc}
-\kactlimport[-l raw]{hash.sh}
-\kactlimport[-l raw]{troubleshoot.txt}
diff --git a/content/data-structures/chapter.tex b/content/data-structures/chapter.tex
index 37f75c2..23a1d74 100644
--- a/content/data-structures/chapter.tex
+++ b/content/data-structures/chapter.tex
@@ -1,16 +1,6 @@
\chapter{Data structures}
-\kactlimport{OrderStatisticTree.h}
-\kactlimport{HashMap.h}
-\kactlimport{SegmentTree.h}
-\kactlimport{LazySegmentTree.h}
-% \kactlimport{UnionFind.h}
\kactlimport{UnionFindRollback.h}
-\kactlimport{SubMatrix.h}
\kactlimport{Matrix.h}
+% Maybe delete
\kactlimport{LineContainer.h}
-\kactlimport{Treap.h}
-\kactlimport{FenwickTree.h}
-\kactlimport{FenwickTree2d.h}
-\kactlimport{RMQ.h}
-\kactlimport{MoQueries.h}
diff --git a/content/geometry/chapter.tex b/content/geometry/chapter.tex
index 9bc4a8b..442d1c4 100644
--- a/content/geometry/chapter.tex
+++ b/content/geometry/chapter.tex
@@ -36,7 +36,6 @@
% \kactlimport{ManhattanMST.h}
\kactlimport{kdTree.h}
% \kactlimport{DelaunayTriangulation.h}
- \kactlimport{FastDelaunay.h}
\section{3D}
\kactlimport{PolyhedronVolume.h}
diff --git a/content/graph/chapter.tex b/content/graph/chapter.tex
index ac07573..739d237 100644
--- a/content/graph/chapter.tex
+++ b/content/graph/chapter.tex
@@ -1,60 +1,11 @@
\chapter{Graph}
-\section{Fundamentals}
- \kactlimport{BellmanFord.h}
- \kactlimport{FloydWarshall.h}
- \kactlimport{TopoSort.h}
-
\section{Network flow}
- \kactlimport{PushRelabel.h}
- \kactlimport{MinCostMaxFlow.h}
- \kactlimport{EdmondsKarp.h}
- % \kactlimport{Dinic.h}
- \kactlimport{MinCut.h}
\kactlimport{GlobalMinCut.h}
\kactlimport{GomoryHu.h}
-\section{Matching}
- \kactlimport{hopcroftKarp.h}
- \kactlimport{DFSMatching.h}
- \kactlimport{MinimumVertexCover.h}
- \kactlimport{WeightedMatching.h}
- \kactlimport{GeneralMatching.h}
-
\section{DFS algorithms}
- \kactlimport{SCC.h}
- \kactlimport{BiconnectedComponents.h}
\kactlimport{2sat.h}
- \kactlimport{EulerWalk.h}
\section{Coloring}
\kactlimport{EdgeColoring.h}
-
-\section{Heuristics}
- \kactlimport{MaximalCliques.h}
- \kactlimport{MaximumClique.h}
- \kactlimport{MaximumIndependentSet.h}
-
-\section{Trees}
- \kactlimport{BinaryLifting.h}
- \kactlimport{LCA.h}
- \kactlimport{CompressTree.h}
- \kactlimport{HLD.h}
- \kactlimport{LinkCutTree.h}
- \kactlimport{DirectedMST.h}
-
-\section{Math}
- \subsection{Number of Spanning Trees}
- % I.e. matrix-tree theorem.
- % Source: https://en.wikipedia.org/wiki/Kirchhoff%27s_theorem
- % Test: stress-tests/graph/matrix-tree.cpp
- Create an $N\times N$ matrix \texttt{mat}, and for each edge $a \rightarrow b \in G$, do
- \texttt{mat[a][b]--, mat[b][b]++} (and \texttt{mat[b][a]--, mat[a][a]++} if $G$ is undirected).
- Remove the $i$th row and column and take the determinant; this yields the number of directed spanning trees rooted at $i$
- (if $G$ is undirected, remove any row/column).
-
- \subsection{Erdős–Gallai theorem}
- % Source: https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Gallai_theorem
- % Test: stress-tests/graph/erdos-gallai.cpp
- A simple graph with node degrees $d_1 \ge \dots \ge d_n$ exists iff $d_1 + \dots + d_n$ is even and for every $k = 1\dots n$,
- \[ \sum _{i=1}^{k}d_{i}\leq k(k-1)+\sum _{i=k+1}^{n}\min(d_{i},k). \]
diff --git a/content/kactl.tex b/content/kactl.tex
index a7270f2..d90515c 100644
--- a/content/kactl.tex
+++ b/content/kactl.tex
@@ -2,14 +2,15 @@
\usepackage{kactlpkg}
\kactlcontentdir{content}
-\university{KTH}{KTH Royal Institute of Technology}{kth}
-\team{Omogen Heap}{Simon Lindholm, Johan Sannemo, Mårten Wiman}
+\university{HPI}{Hasso Plattner Institute}{hpi}
+\team{Burnoutverbot}{Burnoutverbot}
% \contest{ACM-ICPC World Finals 2017}{May 24, 2017}
\contest{\ }{\today}
% \enablecolors
+\include{initial-page}
+
\begin{document}
- \maketeampage
% Small KACTL header on the first page:
% \maketitle{``One Last Time'' Edition}{\today}
\begin{multicols*}{3}
diff --git a/content/math/chapter.tex b/content/math/chapter.tex
index c848ed8..fc138c3 100644
--- a/content/math/chapter.tex
+++ b/content/math/chapter.tex
@@ -16,11 +16,6 @@ In general, given an equation $Ax = b$, the solution to a variable $x_i$ is give
\[x_i = \frac{\det A_i'}{\det A} \]
where $A_i'$ is $A$ with the $i$'th column replaced by $b$.
-\section{Recurrences}
-If $a_n = c_1 a_{n-1} + \dots + c_k a_{n-k}$, and $r_1, \dots, r_k$ are distinct roots of $x^k - c_1 x^{k-1} - \dots - c_k$, there are $d_1, \dots, d_k$ s.t.
-\[a_n = d_1r_1^n + \dots + d_kr_k^n. \]
-Non-distinct roots $r$ become polynomial factors, e.g. $a_n = (d_1n + d_2)r^n$.
-
\section{Trigonometry}
\begin{align*}
\sin(v+w)&{}=\sin v\cos w+\cos v\sin w\\
@@ -53,15 +48,7 @@ Law of sines: $\dfrac{\sin\alpha}{a}=\dfrac{\sin\beta}{b}=\dfrac{\sin\gamma}{c}=
Law of cosines: $a^2=b^2+c^2-2bc\cos\alpha$\\
Law of tangents: $\dfrac{a+b}{a-b}=\dfrac{\tan\dfrac{\alpha+\beta}{2}}{\tan\dfrac{\alpha-\beta}{2}}$\\
-\subsection{Quadrilaterals}
-With side lengths $a,b,c,d$, diagonals $e, f$, diagonals angle $\theta$, area $A$ and
-magic flux $F=b^2+d^2-a^2-c^2$:
-
-\[ 4A = 2ef \cdot \sin\theta = F\tan\theta = \sqrt{4e^2f^2-F^2} \]
-
- For cyclic quadrilaterals the sum of opposite angles is $180^\circ$,
-$ef = ac + bd$, and $A = \sqrt{(p-a)(p-b)(p-c)(p-d)}$.
-
+% Maybe delete
\subsection{Spherical coordinates}
\begin{center}
\includegraphics[width=25mm]{content/math/sphericalCoordinates}
@@ -72,17 +59,6 @@ y = r\sin\theta\sin\phi & \theta = \textrm{acos}(z/\sqrt{x^2+y^2+z^2})\\
z = r\cos\theta & \phi = \textrm{atan2}(y,x)
\end{array}\]
-\section{Derivatives/Integrals}
-\begin{align*}
- \dfrac{d}{dx}\arcsin x = \dfrac{1}{\sqrt{1-x^2}} &&& \dfrac{d}{dx}\arccos x = -\dfrac{1}{\sqrt{1-x^2}} \\
- \dfrac{d}{dx}\tan x = 1+\tan^2 x &&& \dfrac{d}{dx}\arctan x = \dfrac{1}{1+x^2} \\
- \int\tan ax = -\dfrac{\ln|\cos ax|}{a} &&& \int x\sin ax = \dfrac{\sin ax-ax \cos ax}{a^2} \\
- \int e^{-x^2} = \frac{\sqrt \pi}{2} \text{erf}(x) &&& \int xe^{ax}dx = \frac{e^{ax}}{a^2}(ax-1)
-\end{align*}
-
-Integration by parts:
-\[\int_a^bf(x)g(x)dx = [F(x)g(x)]_a^b-\int_a^bF(x)g'(x)dx\]
-
\section{Sums}
\[ c^a + c^{a+1} + \dots + c^{b} = \frac{c^{b+1} - c^a}{c-1}, c \neq 1 \]
\begin{align*}
@@ -92,85 +68,10 @@ Integration by parts:
1^4 + 2^4 + 3^4 + \dots + n^4 &= \frac{n(n+1)(2n+1)(3n^2 + 3n - 1)}{30} \\
\end{align*}
-\section{Series}
-$$e^x = 1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\dots,\,(-\infty<x<\infty)$$
-$$\ln(1+x) = x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+\dots,\,(-1<x\leq1)$$
-$$\sqrt{1+x} = 1+\frac{x}{2}-\frac{x^2}{8}+\frac{2x^3}{32}-\frac{5x^4}{128}+\dots,\,(-1\leq x\leq1)$$
-$$\sin x = x-\frac{x^3}{3!}+\frac{x^5}{5!}-\frac{x^7}{7!}+\dots,\,(-\infty<x<\infty)$$
-$$\cos x = 1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!}+\dots,\,(-\infty<x<\infty)$$
-
+% Maybe delete
\section{Probability theory}
Let $X$ be a discrete random variable with probability $p_X(x)$ of assuming the value $x$. It will then have an expected value (mean) $\mu=\mathbb{E}(X)=\sum_xxp_X(x)$ and variance $\sigma^2=V(X)=\mathbb{E}(X^2)-(\mathbb{E}(X))^2=\sum_x(x-\mathbb{E}(X))^2p_X(x)$ where $\sigma$ is the standard deviation. If $X$ is instead continuous it will have a probability density function $f_X(x)$ and the sums above will instead be integrals with $p_X(x)$ replaced by $f_X(x)$.
Expectation is linear:
\[\mathbb{E}(aX+bY) = a\mathbb{E}(X)+b\mathbb{E}(Y)\]
For independent $X$ and $Y$, \[V(aX+bY) = a^2V(X)+b^2V(Y).\]
-
-\subsection{Discrete distributions}
-
-\subsubsection{Binomial distribution}
-The number of successes in $n$ independent yes/no experiments, each which yields success with probability $p$ is $\textrm{Bin}(n,p),\,n=1,2,\dots,\, 0\leq p\leq1$.
-\[p(k)=\binom{n}{k}p^k(1-p)^{n-k}\]
-\[\mu = np,\,\sigma^2=np(1-p)\]
-$\textrm{Bin}(n,p)$ is approximately $\textrm{Po}(np)$ for small $p$.
-
-\subsubsection{First success distribution}
-The number of trials needed to get the first success in independent yes/no experiments, each which yields success with probability $p$ is $\textrm{Fs}(p),\,0\leq p\leq1$.
-\[p(k)=p(1-p)^{k-1},\,k=1,2,\dots\]
-\[\mu = \frac1p,\,\sigma^2=\frac{1-p}{p^2}\]
-
-\subsubsection{Poisson distribution}
-The number of events occurring in a fixed period of time $t$ if these events occur with a known average rate $\kappa$ and independently of the time since the last event is $\textrm{Po}(\lambda),\,\lambda=t\kappa$.
-\[p(k)=e^{-\lambda}\frac{\lambda^k}{k!}, k=0,1,2,\dots\]
-\[\mu=\lambda,\,\sigma^2=\lambda\]
-
-\subsection{Continuous distributions}
-
-\subsubsection{Uniform distribution}
-If the probability density function is constant between $a$ and $b$ and 0 elsewhere it is $\textrm{U}(a,b),\,a<b$.
-\[f(x) = \left\{
-\begin{array}{cl}
-\frac{1}{b-a} & a<x<b\\
-0 & \textrm{otherwise}
-\end{array}\right.\]
-\[\mu=\frac{a+b}{2},\,\sigma^2=\frac{(b-a)^2}{12}\]
-
-\subsubsection{Exponential distribution}
-The time between events in a Poisson process is $\textrm{Exp}(\lambda),\,\lambda>0$.
-\[f(x) = \left\{
-\begin{array}{cl}
-\lambda e^{-\lambda x} & x\geq0\\
-0 & x<0
-\end{array}\right.\]
-\[\mu=\frac{1}{\lambda},\,\sigma^2=\frac{1}{\lambda^2}\]
-
-\subsubsection{Normal distribution}
-Most real random values with mean $\mu$ and variance $\sigma^2$ are well described by $\mathcal{N}(\mu,\sigma^2),\,\sigma>0$.
-\[ f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \]
-If $X_1 \sim \mathcal{N}(\mu_1,\sigma_1^2)$ and $X_2 \sim \mathcal{N}(\mu_2,\sigma_2^2)$ then
-\[ aX_1 + bX_2 + c \sim \mathcal{N}(\mu_1+\mu_2+c,a^2\sigma_1^2+b^2\sigma_2^2) \]
-
-\section{Markov chains}
-A \emph{Markov chain} is a discrete random process with the property that the next state depends only on the current state.
-Let $X_1,X_2,\ldots$ be a sequence of random variables generated by the Markov process.
-Then there is a transition matrix $\mathbf{P} = (p_{ij})$, with $p_{ij} = \Pr(X_n = i | X_{n-1} = j)$,
-and $\mathbf{p}^{(n)} = \mathbf P^n \mathbf p^{(0)}$ is the probability distribution for $X_n$ (i.e., $p^{(n)}_i = \Pr(X_n = i)$),
-where $\mathbf{p}^{(0)}$ is the initial distribution.
-
-% \subsubsection{Stationary distribution}
-$\mathbf{\pi}$ is a stationary distribution if $\mathbf{\pi} = \mathbf{\pi P}$.
-If the Markov chain is \emph{irreducible} (it is possible to get to any state from any state),
-then $\pi_i = \frac{1}{\mathbb{E}(T_i)}$ where $\mathbb{E}(T_i)$ is the expected time between two visits in state $i$.
-$\pi_j/\pi_i$ is the expected number of visits in state $j$ between two visits in state $i$.
-
-For a connected, undirected and non-bipartite graph, where the transition probability is uniform among all neighbors, $\pi_i$ is proportional to node $i$'s degree.
-
-% \subsubsection{Ergodicity}
-A Markov chain is \emph{ergodic} if the asymptotic distribution is independent of the initial distribution.
-A finite Markov chain is ergodic iff it is irreducible and \emph{aperiodic} (i.e., the gcd of cycle lengths is 1).
-$\lim_{k\rightarrow\infty}\mathbf{P}^k = \mathbf{1}\pi$.
-
-% \subsubsection{Absorption}
-A Markov chain is an A-chain if the states can be partitioned into two sets $\mathbf{A}$ and $\mathbf{G}$, such that all states in $\mathbf{A}$ are absorbing ($p_{ii}=1$), and all states in $\mathbf{G}$ leads to an absorbing state in $\mathbf{A}$.
-The probability for absorption in state $i\in\mathbf{A}$, when the initial state is $j$, is $a_{ij} = p_{ij}+\sum_{k\in\mathbf{G}} a_{ik}p_{kj}$.
-The expected time until absorption, when the initial state is $i$, is $t_i = 1+\sum_{k\in\mathbf{G}}p_{ki}t_k$.
diff --git a/content/number-theory/chapter.tex b/content/number-theory/chapter.tex
index ce18076..f56c1aa 100644
--- a/content/number-theory/chapter.tex
+++ b/content/number-theory/chapter.tex
@@ -5,32 +5,19 @@
\kactlimport{ModInverse.h}
\kactlimport{ModPow.h}
\kactlimport{ModLog.h}
- \kactlimport{ModSum.h}
\kactlimport{ModMulLL.h}
\kactlimport{ModSqrt.h}
\section{Primality}
\kactlimport{FastEratosthenes.h}
- \kactlimport{MillerRabin.h}
- \kactlimport{Factor.h}
\section{Divisibility}
- \kactlimport{euclid.h}
- % \kactlimport{Euclid.java}
- \kactlimport{CRT.h}
-
\subsection{Bézout's identity}
For $a \neq $, $b \neq 0$, then $d=gcd(a,b)$ is the smallest positive integer for which there are integer solutions to
$$ax+by=d$$
If $(x,y)$ is one solution, then all solutions are given by
$$\left(x+\frac{kb}{\gcd(a,b)}, y-\frac{ka}{\gcd(a,b)}\right), \quad k\in\mathbb{Z}$$
- \kactlimport{phiFunction.h}
-
-\section{Fractions}
- \kactlimport{ContinuedFractions.h}
- \kactlimport{FracBinarySearch.h}
-
\section{Pythagorean Triples}
The Pythagorean triples are uniquely generated by
\[ a=k\cdot (m^{2}-n^{2}),\ \,b=k\cdot (2mn),\ \,c=k\cdot (m^{2}+n^{2}), \]
@@ -41,24 +28,7 @@
use 970592641 (31-bit number), 31443539979727 (45-bit), 3006703054056749
(52-bit). There are 78498 primes less than 1\,000\,000.
- Primitive roots exist modulo any prime power $p^a$, except for $p = 2, a > 2$, and there are $\phi(\phi(p^a))$ many.
- For $p = 2, a > 2$, the group $\mathbb Z_{2^a}^\times$ is instead isomorphic to $\mathbb Z_2 \times \mathbb Z_{2^{a-2}}$.
-
\section{Estimates}
$\sum_{d|n} d = O(n \log \log n)$.
The number of divisors of $n$ is at most around 100 for $n < 5e4$, 500 for $n < 1e7$, 2000 for $n < 1e10$, 200\,000 for $n < 1e19$.
-
-\section{Mobius Function}
-\[
- \mu(n) = \begin{cases} 0 & n \textrm{ is not square free}\\ 1 & n \textrm{ has even number of prime factors}\\ -1 & n \textrm{ has odd number of prime factors}\\\end{cases}
-\]
- Mobius Inversion:
- \[ g(n) = \sum_{d|n} f(d) \Leftrightarrow f(n) = \sum_{d|n} \mu(d)g(n/d) \]
- Other useful formulas/forms:
-
- $ \sum_{d | n} \mu(d) = [ n = 1] $ (very useful)
-
- $ g(n) = \sum_{n|d} f(d) \Leftrightarrow f(n) = \sum_{n|d} \mu(d/n)g(d)$
-
- $ g(n) = \sum_{1 \leq m \leq n} f(\left\lfloor\frac{n}{m}\right \rfloor ) \Leftrightarrow f(n) = \sum_{1\leq m\leq n} \mu(m)g(\left\lfloor\frac{n}{m}\right\rfloor)$
diff --git a/content/numerical/chapter.tex b/content/numerical/chapter.tex
index 18969d7..5a19622 100644
--- a/content/numerical/chapter.tex
+++ b/content/numerical/chapter.tex
@@ -4,28 +4,11 @@
\kactlimport{Polynomial.h}
\kactlimport{PolyRoots.h}
\kactlimport{PolyInterpolate.h}
- \kactlimport{BerlekampMassey.h}
- \kactlimport{LinearRecurrence.h}
-
-\section{Optimization}
- \kactlimport{GoldenSectionSearch.h}
- \kactlimport{HillClimbing.h}
- \kactlimport{Integrate.h}
- \kactlimport{IntegrateAdaptive.h}
- \kactlimport{Simplex.h}
\section{Matrices}
\kactlimport{Determinant.h}
\kactlimport{IntDeterminant.h}
\kactlimport{SolveLinear.h}
\kactlimport{SolveLinear2.h}
- \kactlimport{SolveLinearBinary.h}
\kactlimport{MatrixInverse.h}
% \kactlimport{MatrixInverse-mod.h}
- \kactlimport{Tridiagonal.h}
-
-\section{Fourier transforms}
- \kactlimport{FastFourierTransform.h}
- \kactlimport{FastFourierTransformMod.h}
- \kactlimport{NumberTheoreticTransform.h}
- \kactlimport{FastSubsetTransform.h}
diff --git a/content/strings/chapter.tex b/content/strings/chapter.tex
index 7db9b77..e5fa0d1 100644
--- a/content/strings/chapter.tex
+++ b/content/strings/chapter.tex
@@ -1,10 +1,4 @@
\chapter{Strings}
-\kactlimport{KMP.h}
-\kactlimport{Zfunc.h}
\kactlimport{Manacher.h}
\kactlimport{MinRotation.h}
-\kactlimport{SuffixArray.h}
-\kactlimport{SuffixTree.h}
-\kactlimport{Hashing.h}
-\kactlimport{AhoCorasick.h}
diff --git a/content/various/chapter.tex b/content/various/chapter.tex
index dc89331..cd54012 100644
--- a/content/various/chapter.tex
+++ b/content/various/chapter.tex
@@ -38,9 +38,3 @@
\item \lstinline{#pragma GCC optimize ("trapv")} kills the program on integer overflows (but is really slow).
\end{itemize}
\kactlimport{FastMod.h}
- \kactlimport{FastInput.h}
- \kactlimport{BumpAllocator.h}
- \kactlimport{SmallPtr.h}
- \kactlimport{BumpAllocatorSTL.h}
- % \kactlimport{Unrolling.h}
- \kactlimport{SIMD.h}
diff --git a/initial-page.tex b/initial-page.tex
new file mode 100644
index 0000000..3ce09a8
--- /dev/null
+++ b/initial-page.tex
@@ -0,0 +1 @@
+\setcounter{page}{42}