From 92f02961b71c82c91d2968c0b1f392c89d0dc57f Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Thu, 4 May 2017 16:22:27 +0200 Subject: Adding fast Input/Output and Manacher's algorithm. --- other/fastIO.cpp | 24 ++++++++++++++++++++++++ other/other.tex | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 other/fastIO.cpp (limited to 'other') diff --git a/other/fastIO.cpp b/other/fastIO.cpp new file mode 100644 index 0000000..0077ce2 --- /dev/null +++ b/other/fastIO.cpp @@ -0,0 +1,24 @@ +void fastscan(int* number) { + bool negative = false; + register int c; + *number = 0; + c = getchar(); + while(c != '-' && (c < '0' || c > '9')) c = getchar(); + if (c == '-') negative = true, c = getchar(); + for (; c > 47 && c < 58; c = getchar()) *number = *number * 10 + c - 48; + if (negative) *number *= -1; +} + +void printPositive(int n) { + if (n == 0) return; + print(n / 10); + putchar(n % 10 + '0'); +} + +void fastprint(int n) { + if(n == 0) { putchar('0'); return; } + if (n < 0) { + putchar('-'); + print(-n); + } else print(n); +} diff --git a/other/other.tex b/other/other.tex index 7a941bf..b275c6e 100644 --- a/other/other.tex +++ b/other/other.tex @@ -6,6 +6,9 @@ \subsection{Bit Operations} \lstinputlisting{other/bitOps.cpp} +\subsection{Fast IO} +\lstinputlisting{other/fastIO.cpp} + \subsection{Sonstiges} \begin{lstlisting} // Alles-Header. -- cgit v1.2.3