This problem is in Contest(s) below:
Contest 1564:程序设计基础1(学习支持):自定义函数