Задачі
The Balance
The Balance
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure \textbf{200}mg of aspirin using \textbf{300}mg weights and \textbf{700}mg weights, she can put one \textbf{700}mg weight on the side of the medicine and three \textbf{300}mg weights on the opposite side (Figure 1). Although she could put four \textbf{300}mg weights on the medicine side and two \textbf{700}mg weights on the other (Figure 2), she would not choose this solution because it is less convenient to use more weights.
You are asked to help her by calculating how many weights are required.
\includegraphics{https://static.e-olymp.com/content/f1/f1371b3aacc2a7a4247f887be4a82ede8a650460.jpg}
Figure 1. To measure 200mg of aspirin using three 300mg weights and one 700mg weight
\includegraphics{https://static.e-olymp.com/content/0a/0af7489faf062015be202e797ce881829a7e9a43.jpg}
Figure 2. To measure 200mg of aspirin using three 300mg weights and two 700mg weight
\InputFile
The input is a sequence of datasets. A dataset is a line containing three positive integers \textbf{a}, \textbf{b}, and \textbf{d} separated by a space. The following relations hold: \textbf{a} ≠ \textbf{b}, \textbf{a} ≤ \textbf{10000}, \textbf{b} ≤ \textbf{10000}, and \textbf{d} ≤ \textbf{50000}. You may assume that it is possible to measure \textbf{d} mg using a combination of \textbf{a} mg and \textbf{b} mg weights. In other words, you need not consider "\textbf{no solution}" cases.
The end of the input is indicated by a line containing three zeros separated by a space. It is not a dataset.
\OutputFile
The output should be composed of lines, each corresponding to an input dataset (\textbf{a}, \textbf{b}, \textbf{d}). An output line should contain two nonnegative integers \textbf{x} and \textbf{y} separated by a space. They should satisfy the following three conditions.
\begin{itemize}
\item You can measure dmg using \textbf{x} many \textbf{a}mg weights and \textbf{y} many \textbf{b}mg weights.
\item The total number of weights \textbf{(x + y)} is the smallest among those pairs of nonnegative integers satisfying the previous condition.
\item The total mass of weights \textbf{(ax + by)} is the smallest among those pairs of nonnegative integers satisfying the previous two conditions.
\end{itemize}
No extra characters (e.g. extra spaces) should appear in the output.
Вхідні дані #1
700 300 200 500 200 300 500 200 500 275 110 330 275 110 385 648 375 4002 3 1 10000 0 0 0
Вихідні дані #1
1 3 1 1 1 0 0 3 1 1 49 74 3333 1