In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to solve the C++ logic interview questions. The content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this C++ logic interview questions. Let's take a look.
01 the origin of the story
Of the 100 people who answered five questions, 81 answered the first question correctly, 91 answered the second question, 85 answered the third question, 79 answered the fourth question and 74 answered the fifth question.
People who answer three or more questions correctly are counted as passing, so at least how many of these 100 people pass?
02 thinking about small-scale, two questions of AB
First consider if there are only two AB questions, 100 people, the first reaction is to use the way of collection.
In all, there are only the above three cases, of which the number of people in the first one is more than 100 illegal, so there are only the latter two cases.
The following conclusions can be drawn:
At least 72 people got the AB right at the same time, and 81 at the most.
At most 9 people made mistakes in both AB questions and at least 0 people.
It seems that a rule has been found, so follow this idea to further expand the data scale and consider the three questions of ABC.
03 scale expansion, three questions on ABC
Consider the relationship between each two questions first.
And then synthesize the relationship of the three questions. Wait, wait,
Is Xiao K ready to give up, NO,never say give up? Sometimes do not knock down the south wall and do not look back, based on Xiao K's experience for many years, if the law found is not obvious or very complex, it generally means that you are going the wrong way, so consider switching your way of thinking at this time.
04 switch thinking
The above are all positive thinking, but it is difficult to deal with, and you can think in reverse.
As long as you make three mistakes, you will fail. There are a total of 90 mistakes, 15 mistakes, 21 mistakes, 26 mistakes, and 90 mistakes, then a maximum of 30 people will fail, so at least 70 people will pass, perfect, and finish work.
Wait, it always feels a little strange, not because it's too simple, but because my intuition about the amount of information tells me that this solution ignores a lot of information.
Only the total number is used, but not the distribution of the number of wrong questions in 5 questions. Then directly tell you a total of 90 mistakes on the line, why tell the specific number separately, is this really just misleading information?
05 limit method thinking
According to the above solution, since we do not care about the specific distribution, we use extreme thinking to construct special data. For example, all the wrong questions focus on question A.
A total of 90 mistakes, but everyone did the right 4 questions, should be 100 people passed, autistic again.
At this time, I think there should be a lever to jump out.
Xiao K: you have a point. I have nothing to say.
Without talking to you, let's think about it further. This counterexample illustrates one point: wrong questions cannot be shared at will, so let's start from this point.
06 wrong questions are shared equally
Let's first look at the distribution of errors.
How to assign these wrong questions to the most people.
For the convenience of analysis, first write a simple example, such as the distribution of wrong questions is 7, 8, 9, 10, 11.
The first allocation:
Assign AMagol Breco C to 7 people.
Assign Cpeny DPIE to 2 people
Assign BBM DPIE to 1 person
A total of 10 people can be allocated.
The second is to give priority to the allocation of Breco Cpene D, with a total of 11 people.
The third is to give priority to the allocation of C _ Magi D _ pen E, with a total of 12 people.
We have found a pattern here, giving priority to the three channels with the largest distribution will get more people. In the process of distribution, the order of the largest three channels will change dynamically, which inspires the idea of greed.
Sort the wrong questions from big to small
Assign the largest three to one person at a time, and then reorder.
Repeat the above steps until you can't find three numbers that are not zero, that is, to change to XMagol 0memo 0pl 0 or Xmeme Yperio Jo Jol 0.
07 Abstract
Conversion problem: there are 5 rectangles, the order can be arbitrary. To cut out N rectangles with a width of 3, the overall stack should be as high as possible. How much is the highest?
Your taste, your fine taste, is this the same question? So start with the top three and cut it bit by bit, .
08 the truth surfaced
Back to the original question, how many people are there at least? Pass the code test results.
8.1 Code implementation
Int main () {int a [5], ans = 0; for (int I = 0; I
< 5; ++i) { cin >> a [I];} sort (a, a + 5, compare); while (a [2] > 0) {a [0] -; a [1]--; a [2]--; sort (a, a + 5, compare); ans++; for (int I = 0; I < 5; + + I) {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.