Sichuan University Programming Contest 2019 Final Warmup

D: Function