Solved problem

This program fully solves the problem and outputs the correct answer.