solve mathmatics pagoda problem.