Problem 116 solution in very fast C