


Share a logic interview question and see if you can answer it correctly!
This article will share with you a logic interview question (with analysis) whose wrong answer has spread all over the Internet. You can analyze it against yourselves to see if you can answer it correctly!
01 Origin of the story
100 people answered five questions, 81 people answered the first question correctly, 91 people answered the second question correctly, 85 people answered the third question correctly, and 79 people answered the fourth question correctly. , 74 people answered the fifth question correctly.
People who answer three or more questions correctly are considered to have passed. So how many of these 100 people have passed?
02 Think about small scale, two questions AB
First consider if there are only two questions AB, 100 people, first reaction It's done in a collection way.
There are only the above three situations in total. The first one is illegal if the number of people is greater than 100, so only the latter two situations exist.
The following conclusion can be drawn:
There are at least 72 people and a maximum of 81 people who answered questions AB at the same time;
At the same time The maximum number of people who got questions AB and AB wrong was 9 people, and the minimum number was 0 people.
It seems that we have found the pattern, so we will further expand the data scale according to this idea and consider the three ABC questions.
03 Expand the scale, ABC three questions
First consider the relationship between each two questions.
Then synthesize the relationship between the three questions. Wait, it seems a bit complicated. This is not linear complexity. Sorry, little K’s IQ is a bit insufficient and he is autistic.
Is Little K ready to give up? NO, never say give up. Sometimes, don’t hit the wall and never look back. Based on Xiao K’s years of experience, if the pattern you find is not obvious or very complicated, it usually means you are on the wrong track, so you should 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, so you can think in reverse.
As long as you make 3 wrong questions, you will fail. There are 19 9 15 21 26 = 90 wrong questions in total. Then 90/3 = 30, then at most 30 people will fail. , so at least 70 people pass, perfect, and call it a day.
Wait always feels a bit weird, not because it is 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 the distribution of the number of wrong questions for the 5 questions is not used. Then just tell you that there are 90 errors in total. Why do you have to tell the specific number separately? Is this really just misleading information?
05 Extreme thinking
According to the above solution, since you don’t care about the specific distribution, use extreme thinking to construct special data. For example, all wrong questions are concentrated in question A.
There are still 90 questions wrong in total, but everyone got 4 questions right, so 100 people should have passed, and they are autistic again.
At this time, I think there should be a barrage spirit about to jump out.
Little K: What you said makes sense, but I am speechless.
I won’t bullshit you, let’s think about it further. This counterexample illustrates one point: wrong questions cannot be shared evenly at will, so let’s start from this point.
06 Wrong questions are evenly distributed
First look at the distribution of errors.
How to distribute these wrong questions to the most people.
For the convenience of analysis, let’s first write a simple example. For example, the distribution of wrong questions is 7, 8, 9, 10, and 11.
The first allocation:
Assign A, B, and C to 7 people
Assign C, D, Assign E to 2 people
Assign B, D, and E to 1 person
A total of 7 2 1=10 people can be assigned.
In the second type, priority is given to B, C, and D, a total of 11 people.
The third type, priority is given to C, D, and E, a total of 12 people.
#Here we have discovered the pattern. Prioritizing the three largest channels will get more people. During the allocation process, the largest three orders will change dynamically, which inspires the idea of greed.
Sort the wrong questions from largest to smallest;
Assign the top 3 largest questions to one person each time, and then reorder.
Repeat the above steps until finally no three numbers that are not 0 can be found, that is, it becomes X,0,0,0,0 or X,Y,0,0,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 superposition must be as high as possible. What is the highest?
You taste it, you taste it carefully, is this the same problem? So start with the top 3 and chip away at it, haha.
08 The truth emerges
Back to the original question, how many people are there at least? Pass 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 << a[i] << " "; } cout << endl; } cout << "ans=" << ans << endl; return 0; }
8.2 Data Test
25 20 18 15 9 24 19 17 15 9 23 18 16 15 9 22 17 15 15 9 21 16 15 14 9 20 15 14 14 9 19 14 14 13 9 18 13 13 13 9 17 13 12 12 9 16 12 12 11 9 15 11 11 11 9 14 11 10 10 9 13 10 10 9 9 12 9 9 9 9 11 9 9 8 8 10 8 8 8 8 9 8 8 7 7 8 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 4 5 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 1 2 1 1 1 1 1 1 1 0 0 0 0 0 0 0 ans=30
So at most 30 people fail, and at least 70 people pass. Although the answers are the same, the way of thinking is different.
09 Summary
You should think more deeply about seemingly simple questions, maybe you will find different conclusions. And don’t easily believe other people’s analysis. 90% of the people on the Internet are wrong about this issue. You can also check whether my analysis is rigorous. If you have any questions, please leave a message and give feedback. Thank you.
Related recommendations: "C Language Video Tutorial", "PHP Video Tutorial"
The above is the detailed content of Share a logic interview question and see if you can answer it correctly!. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Written above & the author’s personal understanding: At present, in the entire autonomous driving system, the perception module plays a vital role. The autonomous vehicle driving on the road can only obtain accurate perception results through the perception module. The downstream regulation and control module in the autonomous driving system makes timely and correct judgments and behavioral decisions. Currently, cars with autonomous driving functions are usually equipped with a variety of data information sensors including surround-view camera sensors, lidar sensors, and millimeter-wave radar sensors to collect information in different modalities to achieve accurate perception tasks. The BEV perception algorithm based on pure vision is favored by the industry because of its low hardware cost and easy deployment, and its output results can be easily applied to various downstream tasks.

Common challenges faced by machine learning algorithms in C++ include memory management, multi-threading, performance optimization, and maintainability. Solutions include using smart pointers, modern threading libraries, SIMD instructions and third-party libraries, as well as following coding style guidelines and using automation tools. Practical cases show how to use the Eigen library to implement linear regression algorithms, effectively manage memory and use high-performance matrix operations.

The bottom layer of the C++sort function uses merge sort, its complexity is O(nlogn), and provides different sorting algorithm choices, including quick sort, heap sort and stable sort.

The convergence of artificial intelligence (AI) and law enforcement opens up new possibilities for crime prevention and detection. The predictive capabilities of artificial intelligence are widely used in systems such as CrimeGPT (Crime Prediction Technology) to predict criminal activities. This article explores the potential of artificial intelligence in crime prediction, its current applications, the challenges it faces, and the possible ethical implications of the technology. Artificial Intelligence and Crime Prediction: The Basics CrimeGPT uses machine learning algorithms to analyze large data sets, identifying patterns that can predict where and when crimes are likely to occur. These data sets include historical crime statistics, demographic information, economic indicators, weather patterns, and more. By identifying trends that human analysts might miss, artificial intelligence can empower law enforcement agencies

01 Outlook Summary Currently, it is difficult to achieve an appropriate balance between detection efficiency and detection results. We have developed an enhanced YOLOv5 algorithm for target detection in high-resolution optical remote sensing images, using multi-layer feature pyramids, multi-detection head strategies and hybrid attention modules to improve the effect of the target detection network in optical remote sensing images. According to the SIMD data set, the mAP of the new algorithm is 2.2% better than YOLOv5 and 8.48% better than YOLOX, achieving a better balance between detection results and speed. 02 Background & Motivation With the rapid development of remote sensing technology, high-resolution optical remote sensing images have been used to describe many objects on the earth’s surface, including aircraft, cars, buildings, etc. Object detection in the interpretation of remote sensing images

1. The historical development of multi-modal large models. The photo above is the first artificial intelligence workshop held at Dartmouth College in the United States in 1956. This conference is also considered to have kicked off the development of artificial intelligence. Participants Mainly the pioneers of symbolic logic (except for the neurobiologist Peter Milner in the middle of the front row). However, this symbolic logic theory could not be realized for a long time, and even ushered in the first AI winter in the 1980s and 1990s. It was not until the recent implementation of large language models that we discovered that neural networks really carry this logical thinking. The work of neurobiologist Peter Milner inspired the subsequent development of artificial neural networks, and it was for this reason that he was invited to participate in this project.

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

Written above & The author’s personal understanding is that in the autonomous driving system, the perception task is a crucial component of the entire autonomous driving system. The main goal of the perception task is to enable autonomous vehicles to understand and perceive surrounding environmental elements, such as vehicles driving on the road, pedestrians on the roadside, obstacles encountered during driving, traffic signs on the road, etc., thereby helping downstream modules Make correct and reasonable decisions and actions. A vehicle with self-driving capabilities is usually equipped with different types of information collection sensors, such as surround-view camera sensors, lidar sensors, millimeter-wave radar sensors, etc., to ensure that the self-driving vehicle can accurately perceive and understand surrounding environment elements. , enabling autonomous vehicles to make correct decisions during autonomous driving. Head
