Add a cpp program which can solve the problem