solve some dp problems