Little Sub and Mr.Potato's Math Problem

ZOJ - 4085