%https://nl.wikipedia.org/wiki/Rij_van_Fibonacci
\documentclass{article}
\input{preamble}
\title{Decimal Determination - MathGames}

\begin{document}

\maketitle
{\bf Difficulty:} \stars{4}\\
{\bf Key words: Algebra} \\
Several real numbers have algorithms that allow for efficient computation of a specific digit, without needing to compute the prior digits. For instance, the Bailey–Borwein–Plouffe formula
$$
\pi = \sum_{k=0}^{\infty}\left[\frac{1}{16^k}\left(\frac{4}{8k+1} - \frac{2}{8k+4} - \frac{1}{8k+5} - \frac{1}{8k+6}\right)\right]
$$
can be exploited to efficiently compute a single digit of $\pi$ in base $16$. In this problem, we instead look at numbers of the form
$$
D(A, B, s) := \frac{1}{1 - 0.\underbrace{0\ldots0}_{s \ \textnormal{zeroes}}A\underbrace{0\ldots0}_{s \ \textnormal{zeroes}}B}
$$
with $s \in \mathbb{Z}_{> 0}$ and $A,B \in \{0,1,\ldots,9\}$. The decimal expansion of such numbers has a nice property that allows for efficient computation of specific digits.\\


{\Large \textbf Input}
\begin{itemize}
    \item The first line consists of three space-separated integers $A, B, s$ with $A,B \in \{0,1,\ldots,9\}$ and $0 < s \leq 10^6$, the parameters of $D(A, B, s)$ as described above.
    \item The second line consists of a single integer $0 < d \leq s(s+1)$, the index of the specific digit to calculate.
\end{itemize}

{\Large \textbf Output}
\begin{itemize}
    \item A single integer, the $d^{th}$ decimal digit of $D(A, B, s)$ after the decimal point.
\end{itemize}


{\Large \textbf Examples}\\
\begin{center}
\scalebox{1.5}{
\begin{tabular}{|l|l|}
\hline
Input & Output \\ \hline
1 1 4 & 5\\
20 & \\ \hline
\end{tabular}
}

\vspace{1em}

\scalebox{1.5}{
\begin{tabular}{|l|l|}
\hline
Input & Output \\ \hline
3 8 500 & 4\\
249876&\\\hline\end{tabular}
}
\end{center}


\end{document}