COJ problem 1000 c# solution.