zoukankan      html  css  js  c++  java
  • A funny question

    Q:Every man in a village of 100 married couples has cheated on his wife. Every wife in the village instantly knows when a man other than her husband has cheated, but does not know when her own husband has. The village has a law that does not allow for adultery. Any wife who can prove that her husband is unfaithful must kill him that very day. The women of the village would never disobey this law. One day, the queen of the village visits and annoces that at least one husband has benn unfaithful. What happens?

    A:The queen said "at least one husband", so maybe more than one husband has been unfaithful.

    1. There is only one cheat husband. Assume the husband is A.

     First day, 99 wives except A's wife know A is unfaithful, but A know none of husbands is unfaithful. so A got the information from queen that her husband is cheeting. So she kill her husband, everything is over.

    2. There are two cheat husband. Assume they are A & B.

     First day, every wives know someone of husbands are unfaithful. So no man die. 

     Second day, because no one die in first day.Wives know there are more than one husband are cheeting, but A's wife and B's wife only know one, so they will kill their husbands.

    Same goes to 3,4,5...100 cheeting husbands.

    Conclusion:

     If there are N cheeting husband, in prime N-1 days, no husband have been killed, at the Nth day, N hasbands will be killed by their wives. 

  • 相关阅读:
    Java中数组遍历
    数组常见异常
    数组的访问
    Java中数组的定义方式
    Java中数组的概念与特点
    node爬虫技术初探
    node相关内容
    vs code快捷键
    vue 入门开发
    es6 常见用法
  • 原文地址:https://www.cnblogs.com/triStoneL/p/1905312.html
Copyright © 2011-2022 走看看