本文介绍了黑或白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下:


有n个人,其中n可以是任意数字。这两个人在一条线上,所以他们看不到任何人在他们身后,但是他们可以看到每个人都在他们面前。

坏人给每个人戴上帽子,帽子可以是黑色的或白色(随机,所以可以有n个白帽子,或者可以有黑色或任何可能的组合)。


每个人都可以在他面前看到那些家伙的帽子,但他看不到自己的帽子或任何身后的帽子。


他们开始从他们的帽子的颜色后面询问(第一个将是能看到除了他的每个帽子的人)。如果他们猜测他们的帽子颜色,他们就被释放,如果不是...... =(他们被杀了。


幸运的是他们是一个训练有素的团队,他们设法幸存下来(实际上他们的战略并不完美,他们中的一个人有可能被杀),你能说出战略是什么吗?

解决方案

Picture this:

There are n guys, where n can be any number. This n guys are in a line so they can''t see anyone behind them, but they can see everyone in front of them.
The bad guys put a hat on everyone, the hat can be black or white (at random, so there can be n white hats or there can be n black or any possible combination).

Every guy can see the hats of the guys in front of him, but he cannot see his own hat or any behind him.

They start asking from behind their hat''s color (the first one will be the one who can see every hat but his). If they guess their hat color, they''re set free, if not... =( they get killed.

Fortunately they''re a well trained group and they manage to survive all (actually their strategy is not perfect, there''s a chance that one of them get killed), can you tell what the strategy is??

解决方案




这篇关于黑或白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 10:36