1. N A hat with a red and yellow color. Everyone can see the hats of everyone else, but they can't see their own. Start with the last person and report the color of your hat. Q, what strategy would you have in advance to make the final report on the color of the hat at least N-1? (No color blindness) can also be extended to M colors ... Strategy: For the M type hat number, and weighted, so that the weight of No. 0 color hat is 1, 1th color hat weight is 2.,m-1 hat color is M, the last number of people in front of all the hat color number, and multiplied by the difference of weight, add a number sum to calculate the t=sum%m, this number, Must be a number between the 0-m-1. The last person reported the color of the hat for this number. Other people remember this color and change into a number T. Other people see except the last person and the color of their hats, also in the same way calculated, get the number if it is P, (p-t+m)%m is the color of their own hats ... This source http://daiyanfei.blog.51cto.com/698782/215149
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.