https://www.acwing.com/problem/content/4510/