Teaching LLMs According to Their Aptitude: Adaptive Reasoning for Mathematical Problem Solving