\documentclass{article}

% Macros to make this problem look like the rest of our problems.
\usepackage{icpc_problem}

% Title of your problem.
\title{Diophantine Equation}

% Who made the problem
\author{Anany Levitin}

% Keywords, from a set of standard keywords.
\keywords{simple}

% Anything you want to say about the problem, including how one could solve it
\comments{We often use this problem for a practice problem in local contests.}

% Difficulty on a 1..10 scale.
\difficulty{1}

\begin{document}

\begin{problemDescription}
The {\em extended Euclid's algorithm} determines not only the greatest
common divisor $d$ of two positive integers $m$ and $n$ but
also integers (not necessarily positive) $x$ and $y$, such that
$mx + ny = d$.  Modify the algorithm to find integer solutions to the
Diophantine equation $ax + by = c$ with any set of integer 
coefficients $a$, $b$, and $c$ (non-zero $a$ and $b$).
\end{problemDescription}

\begin{inputDescription}
There may be multiple cases.  Each case will be presented on a separate
line with the three integer coefficients $a$, $b$, and $c$ separated
by white space.  The last case will be followed by a line containing
a 0 (zero) for $a$ and/or $b$.  All integers will fit within 32 bit signed
notation.
\end{inputDescription}

\begin{outputDescription}
For each case display the case number and the particular solution, if it
exists, formatted as in the Sample Output.  If either $x$ and/or $y$ is 
ambiguous, say so.  If there is no solution, say so.
\end{outputDescription}

\begin{sampleInput}
  2    5   20
1027   712   1
   51   712   0
 -2    5  20
4  0      8
\end{sampleInput}

\begin{sampleOutput}
Case 1: -40 20
Case 2: -165 238
Case 3: 0 0
Case 4: 140 60
\end{sampleOutput}

\end{document}
