https://www.luogu.org/problemnew/solution/P1042?page=2