P2823 must use scanf and printf, otherwise, Time Limit Exceeded