Does anyone have common logical reasoning problems in java interviews? Share it.

1. A long straight tube with uniform thickness, with openings at both ends, contains four white balls and four black balls. The diameter of the ball and the openings at both ends are equal to the inner diameter of the tube. Now the arrangement of white balls and black balls is wwwwbbbb, and it is required not to take out any balls, so the arrangement becomes bbwwwwbb.

2. A snail climbed from the bottom of the well to the wellhead. Every day, snails sleep and come out at night. One night, the snail can climb 3 feet, but it will fall 2 feet when sleeping during the day, and the depth of the well is 10 feet. How many days can a snail crawl out?

3. Drawing 1999 straight lines can divide a plane into several parts?

An island in the Pacific Ocean is inhabited by aborigines. They don't want to be disturbed by outsiders. One day, an explorer came to the island and was caught by the locals. The native priest told him that you can leave a message again before you die. If this sentence is true, you will be burned to death. If it is false, you will be dismembered. How does the poor explorer survive?

5. How to plant four trees so that the distance between any two trees is equal?

6.27 Young athletes are thirsty after participating in the competition, so they go to small shops to buy drinks and drink shops to promote sales. With three empty bottles, they can exchange them for another bottle. How many bottles can they buy at least to ensure one bottle for each person?

7. There is a mountain. There is a temple on the hill. There is only one way from the temple on the mountain to the foot of the mountain. At 8 o'clock every Monday morning, a clever little monk goes to the foot of the mountain for alms, and at 8 o'clock on Tuesday morning, he returns to the temple on the mountain. The speed of going up and down the mountain is arbitrary. In every round trip, he can always reach the same point on the mountain road at the same time on Monday and Tuesday. For example, once he found that at 8: 30 on Monday and 8: 30 on Tuesday, he walked to three-quarters of the mountain road near the foot of the mountain and asked why.

8. There are two unevenly distributed incense, and the burning time of each incense is one hour. What method can you use to determine the time of 15 minutes?

2. 10 pirates robbed 100 gems, each of which is the same size and priceless. They decided to divide it like this:

(1) Draw lots to decide your own number (1~10);

(2) First, 1 put forward the distribution plan, and then everyone voted. When and only when more than half of the people agree, they will be distributed according to his plan, otherwise they will be thrown into the sea to feed sharks;

(3) If 1 dies, No.2 puts forward a distribution plan, and then the remaining four people vote. If and only if more than half of the people agree, they will be distributed according to his plan, otherwise they will be thrown into the sea to feed sharks;

(4) and so on ...

Conditions: Every pirate is a very smart person who can make rational judgments and make choices.

Question: What kind of distribution scheme does the first pirate propose to maximize his income?

12. Planes of the same model start from the same place, but each plane can only fly around the earth for half a week with full fuel, and it can refuel between planes, and the plane that has finished refueling must return to the starting point. Ask at least how many flights are needed to meet the demand of a plane circling the earth once.

Reference answer:

1. Burn both sides together.

2.96,0, 1,0, 1,0, 1,0, 1,0。

3. Because the mouth is round.

4. A lot.

5. 1, 2, 4.

6.6/7 Distance from Beijing to Guangzhou.

7. 100%。

8. Plane mirror imaging principle (or "eyes are left and right").

9.3 Fill it first, pour it into 5 Li, then fill it with 3 Li and pour it into 5 Li. Pour out the water in 5 Li, pour the remaining water in 3 Li into 5 Li, then fill 3 Li and pour it into 5 Li, ok!

10. Once.

1 1. First, 1000 is a solution. The average value of consecutive numbers is set to X, and 1000 must be an integer multiple of X. If the number of consecutive numbers is even, then X is not an integer. 2 times of x can only be 5,25, 125. Because the average value is 12.5, it will not reach 80 continuously. 125/2=62.5 will do. That is, 62,63,6164, and so on. When the number of consecutive numbers is odd, the average value is an integer. 1000 is an odd multiple of the average. 1000=2×2×2×5×5×5; X can be 2, 4, 8, 40, 200, or 40, 200 after division. So the answer is four groups of integers with an average value of 62.5, 40,200, 1000.

12. The answer is 5 sorties. The general solution can be divided into the following two parts:

(1) flying in a straight line

The flight distance of the plane with full fuel is 1. How far can n planes fly? The question is, how far can n planes fly? The extreme problem is not to fly repeatedly, such as two planes at the same time.

A plane refuels and flies back at the same time, which can be regarded as repetition, or in other words, the farther away from the starting point, the fewer planes fly. This extreme condition is obvious, because the oil carried by N planes is certain. If it is repeated, the more oil will be wasted. For example, there must be only one plane flying all the way in the end. Pay attention to the word "all the way", which is an extreme situation that should not be repeated. If it's two planes, one plane must have filled the other plane with oil, so that the remaining oil can just go back, that is to say, the fuel consumption of the second plane is three times that of the take-off to refuel, and the fuel consumption of the third plane of the three planes is five times that of the take-off to refuel, so the farthest distance that N planes can fly is S = 1+ 1/3+…

) This series is divergent, so in theory, as long as there are enough planes, one plane can eventually fly to infinity. Of course, it is actually impossible for an aircraft to refuel n- 1 aircraft at the same time during the flight time of1(2n+1).

(2) You can meet head-on and come on.

The flight distance of the plane with full fuel is 1/2. How many planes can fly at least 1? It is also based on the extreme condition of non-repeated flight that the farthest distance must be only one plane flying, so the symmetrical edge at 1/2 is 1/4.

When an airplane flies, we can know from the above formula that one side needs at least two airplanes to support it, (1/3+1/5)/2 > 1/4 (dividing the left by 2 means that the flight distance of the plane is 1/2), but there is still a little bit left, so think of it as a pulley (middle).

If one plane is a rope, two planes on both sides are great), you can slide a little distance, that is to say, you can change the refueling location within a certain distance (it is easy to calculate the refueling location and amount of each plane, etc.). )