Comments

Thank you,I got it.

In problem D,Why the ans should become ans — 1?

Nice solution! Very clear.