Codeforces 877D

Can Anybody give a better explanation to this problem Problem - D - Codeforces