Solutions of UVa Problem of Competitive Programming 3