IBM interview questions (about 50 dogs, 50 people, sick dogs)

xiaoxiao2021-03-06  49

Title: There are 50 people in the village, each has a dog, there is a disease in these 50 dogs (this disease is not infected), so people want to find out the dog. Everyone can observe other 49 dogs to determine if they are sick, (if there is a disease, you can see) Once the owner is, the dog is a dog is a sick dog is a dog, which is a dog (you must shoot in one day), and everyone only has the right to shoot her own dog, there is no right to kill other people. Dog.

On the first day, everyone was finished, but the gun didn't ring. After the third day, a gunshot came, and asked a few sick dogs in the village, how to calculate it?

Analysis: 1). Suppose there is only one sick dog. At this time, only one person did not see a disease, the other 49 saw a dog. People who can't see the sick dog can be inferred that their dog is a sick dog, so it is not established. So the dick dog is more than one.

2) Assume that there are two sick dogs. At this time, two people saw that there was only one sick dog, and the remaining 48 people saw two sick dogs. No one kills the dog after the first day. So I saw that only one sick dog can be combined with a conclusion that the dog is actually more than one, so she only sees, so her dog is also a sick dog, then kills the dog. Therefore, it is assumed that the second is not established. So therefore the disease dog is more than two.

3) Assume that there are three sick dogs. There are three people who have two dogs, and the remaining 47 people have three dogs. Naturally no one kills the dog in front of two days. On the third day, I saw that the three people with only two dogs (according to the previous inferior) Know that the disease is more than two, but they have seen two, so their dog is also a sick dog, then the three people will shoot together . This assumption is consistent with the topic.

As for this program? Use a test method?

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

New Post(0)