solution to UVA 10901