Solution to UVA problem 151: Power Crisis