solutions to ZOJ problems