summaryrefslogtreecommitdiff
path: root/sonstiges
diff options
context:
space:
mode:
Diffstat (limited to 'sonstiges')
-rw-r--r--sonstiges/bitOps.cpp15
-rw-r--r--sonstiges/josephus2.cpp2
-rw-r--r--sonstiges/josephusK.cpp2
-rw-r--r--sonstiges/sonstiges.tex28
-rw-r--r--sonstiges/split.cpp9
5 files changed, 46 insertions, 10 deletions
diff --git a/sonstiges/bitOps.cpp b/sonstiges/bitOps.cpp
index b882965..b75304f 100644
--- a/sonstiges/bitOps.cpp
+++ b/sonstiges/bitOps.cpp
@@ -1,15 +1,14 @@
-//lsb: 0-th bit, msb: n-th bit
-//get j-th bit
+// Bit an Position j auslesen.
(a & (1 << j)) != 0
-//set j-th bit
+// Bit an Position j setzen.
a |= (1 << j)
-//clear j-th bit
+// Bit an Position j löschen.
a &= ~(1 << j)
-//toggle j-th bit
+// Bit an Position j umkehren.
a ^= (1 << j)
-//get value of least significant bit set
+// Wert des niedrigsten gesetzten Bits.
(a & -a)
-//turn on all bits
+// Setzt alle Bits auf 1.
a = -1
-//turn on first n bits (be aware of overflows)
+// Setzt die ersten n Bits auf 1. Achtung: Overflows.
a = (1 << n) - 1
diff --git a/sonstiges/josephus2.cpp b/sonstiges/josephus2.cpp
index 7676e3c..c0bcc2f 100644
--- a/sonstiges/josephus2.cpp
+++ b/sonstiges/josephus2.cpp
@@ -1,4 +1,4 @@
-int rotateLeft(int n) { //returns the number of the last survivor (1 based)
+int rotateLeft(int n) { // Gibt Index des letzten Überlebenden zurück, 1-basiert.
for (int i = 31; i >= 0; i--)
if (n & (1 << i)) {
n &= ~(1 << i);
diff --git a/sonstiges/josephusK.cpp b/sonstiges/josephusK.cpp
index e3fcac2..8758fee 100644
--- a/sonstiges/josephusK.cpp
+++ b/sonstiges/josephusK.cpp
@@ -1,4 +1,4 @@
-int josephus(int n, int k) { //returns the number of the last survivor (0 based)
+int josephus(int n, int k) { // Gibt Index des letzten Überlebenden zurück, 0-basiert.
if (n == 1) return 0;
return (josephus(n - 1, k) + k) % n;
} \ No newline at end of file
diff --git a/sonstiges/sonstiges.tex b/sonstiges/sonstiges.tex
index b2d9009..8148dbf 100644
--- a/sonstiges/sonstiges.tex
+++ b/sonstiges/sonstiges.tex
@@ -8,6 +8,9 @@
\item Genau dann lösbar, wenn keine Variable mit ihrer Negation in einer SCC liegt.
\end{enumerate}
+\subsection{Zeileneingabe}
+\lstinputlisting{sonstiges/split.cpp}
+
\subsection{Bit Operations}
\lstinputlisting{sonstiges/bitOps.cpp}
@@ -59,3 +62,28 @@ $n$ Personen im Kreis, jeder $k$-te wird erschossen.
Lösung: Sortiere Knoten links aufsteigend nach Gewicht, danach nutze normlen Algorithmus (\textsc{Kuhn}, Seite \pageref{kuhn})
\item \textbf{Tobi, cool down!}
\end{itemize}
+
+\subsection{Sonstiges}
+\begin{lstlisting}
+// Alles-Header.
+#include <bits/stdc++.h>
+
+// Setzt das deutsche Tastaturlayout.
+setxkbmap de
+
+// Schnelle Ein-/Ausgabe mit cin/cout.
+ios::sync_with_stdio(false);
+
+// Set mit eigener Sortierfunktion. Typ muss nicht explizit angegeben werden.
+set<point2, decltype(comp)> set1(comp);
+
+// PI
+#define PI (2*acos(0))
+
+// STL-Debugging, Compiler flags.
+-D_GLIBCXX_DEBUG
+#define _GLIBCXX_DEBUG
+
+// 128-Bit Integer. Muss zum Einlesen/Ausgeben in einen int oder long long gecastet werden.
+__int128
+\end{lstlisting}
diff --git a/sonstiges/split.cpp b/sonstiges/split.cpp
new file mode 100644
index 0000000..ea7d5ff
--- /dev/null
+++ b/sonstiges/split.cpp
@@ -0,0 +1,9 @@
+vector<string> split(string &s, string delim) { // Zerlegt s anhand aller Zeichen in delim.
+ vector<string> result; char *token;
+ token = strtok((char*)s.c_str(), (char*)delim.c_str());
+ while (token != NULL) {
+ result.push_back(string(token));
+ token = strtok(NULL, (char*)delim.c_str());
+ }
+ return result;
+} \ No newline at end of file