add problem 1847.cpp