dp

almost same with p1009