solutions for UVa problems