Answer: they choose an accountant. Each of the other 99 prisoners must send exactly two signals: each time they enter and find the light bulb out, they turn it on, until they have done so twice in total. The strategy is this: - Before starting, they designate a prisoner as an accountant.
- Each prisoner other than the counter keeps his own account of signals sent.
- If one of them enters, sees the light bulb off and has still sent less than two signals, he turns it on.
- If you have already sent your two signals, you do not touch the bulb again.
- If you enter and the light bulb is on, it does nothing.
- The accountant, every time he enters and sees the light bulb on, turns it off and adds 1 to his account.
- When the counter reaches 198, it declares that everyone has passed through the room. Why does it work? There are 99 prisoners who are not the counter, and each one must provide two signals: $$
99\cdot 2=198.
$$ If the light bulb started off, the 198 signals counted necessarily come from those 99 prisoners. Therefore, all of them have passed. If the light bulb started off, the counter might initially count a signal that was not sent by any prisoner. But even in that case, by the time we reach 198 counts, at least 197 real signals will have been produced by the non-counters. If any of the 99 non-accountants had never been in the room, the other 98 could only contribute at most: $$
98\cdot 2=196
$$ real signs. Adding the possible false initial signal, the counter could not reach 198. Therefore, when the counter reaches 198, all non-counters have passed at least once. And the accountant has also passed, because he himself has entered to count. This way you can state with certainty that everyone has been in the room.