IBM interview questions (reproduced)

zhaozj2021-02-16  168

50 people in the village, each has a dog. There is a disease in these 50 dogs (this disease will not be infected). So people will find out the dog. Everyone can observe other 49 dogs to determine if they are sick, only their dogs can't see. The results obtained after observation must not be exchanged, and the owner of the disease dog cannot be notified. Once the owner is, the owner is a sick dog, it is to shoot his dog, and everyone only has the right to shoot her own dog, there is no right to kill other people. On the first day, there was no gun on the next day. I came to the third day, I came, asked if there were several diseased dogs, how to calculate it?

First inference:

A, a false dog, the owner of the sick dog will see that other dogs don't have sick, then they know that their dogs have sick, so there will be guns in the first night. Because there is no gun, the number of dicks is greater than 1.

B, there is a doped dog, the owner of the sick dog will see there is a doped dog, because did not hear the gun on the first day, the number of sick dogs greater than 1, so the sick dog's owner will know that his dog is Daughter, there will be a gun on the next day. Since there is also a gun on the next day, the number of dick dogs is greater than 2.

From this reason, there is three disease dogs if the third day is shot.

Second Inference

1 If it is 1, the dog must die because the dog owner did not see the dog, but the disease dog exists.

2 If 2, the sick dog owner is A, B. a See a sick dog, but I also saw a dog, but a sick dog who saw B did not die, the number of dogs did not be 1, and others did not sick dog, so their dog must be a sick dog, so they open Gun; and B's idea is like a, so it also shines.

Thus, when 2, the next day, two dogs must die.

3 If it is 3, the dog owner is A, B, and C. A first day, I saw 2 sick dogs. If a set yourself is not a sick dog, it is reasoning 2, the next day, the 2 dogs are not dead, the number of dogs is definitely 2, and others have no sick dog So your dog must be a sick dog, so I shoot it; and the idea of ​​B and C is the same as A, so I also shot.

Thus, when 3, three dogs were killed the next day.

4 If 4, the dog owner is A, B, C, D. A first day, I saw three diseased dogs. If a set yourself is not a sick dog, from the reasoning 3, the third day, the three dogs are not dead, the number of dogs is definitely not 3, while others have no sick dog , So your dog must be a sick dog, so I shoot it; and the idea of ​​B and C, D is like a, so I also shot.

Thus, 4 times, 4 dogs will die after the third day.

After more than 5, it was pushed, and n was launched by N-1 year.

Answer: n is 4. At the fourth day, the dog was dead, but in the third day, the answer was 3

转载请注明原文地址:https://www.9cbs.com/read-9043.html

New Post(0)