UVa 284 - Logic

For an extensive tutorial on a plausible algorithm for this problem, you may refer to:

284 Logic