An Inverse Optimality Method to Solve a Class of Optimal Control Problems