Problem #PRU-66710

Problems Number theory

Problem

The king decided to reward a group of \(n\) wise men. They will be placed in a row one after the other (so that everyone is looking in the same direction), and each is going to wear a black or a white hat. Everyone will see the hats of everyone in front, but not those behind them. The wise men will take turns (from the last to the first) to name the color (white or black) and the natural number of their choice.
At the end, the number of sages who have named the color of their hat correctly is counted: that is exactly how many days the whole group will be paid a salary raise. The wise men were allowed to agree in advance on how to respond. At the same time, the wise men know that exactly \(k\) of them are insane (they do not know who exactly). Any insane man names the color white or black, regardless of the agreement. What is the maximum number of days with a pay supplement that the wise men can guarantee to a group, regardless of the location of the insane in the queue?