Solution to problems in UVA Online Judge