Chapter 230 There are mountains beyond the mountains
The first program practical question that I personally answered was of average difficulty. It was a basic question that gave me ideas right after reading it and didn’t have too many stuck points.
Test basic skills and proficiency.
As soon as Li Yan finished reading the questions and was about to start, he glanced at the big screen and saw another prompt:
"The second place to complete the first stage questions: B-7, New Taipei Middle School, Deng Yudi, Time taken 29:28”
At the moment when he was distracted, there was a third item:
"The third person completed the first stage question: A-11, Xin'an Middle School, Zheng Da, in 29:30"
< br>Li Yan knew who this person was. He was a potential player in Xinan Middle School that should really be taken seriously. In his freshman year of high school, he ranked second in the league's high school improvement group. The first place was none other than Deng Yudi.
Li Yan smiled and nodded slightly, feeling that she had indeed seen the right person, but she also had a little more sense of urgency.
It's good, it gives me a feeling of competition.
Invincible will indeed be lonely, so he needs a bigger stage, even if it is some setbacks, it doesn't matter.
The screen only displays the first three completed data. Judging from the display ratio, it should be that the top three completed records of the three stages will be displayed on top at the same time... If all three stages are completed first, indeed It can give you a strong sense of presence.
Li Yan did not want to be distracted, and indeed he was not distracted. Just by glancing at it, my mind was busy analyzing a lot of things.
The movements of the hands are non-stop, and the basic question ideas are just like that. In terms of speed, the test is still the proficiency in writing code.
Soon this question was solved. Li Yan confidently clicked submit and saw the next question:
A prime number is a number that has only two divisors: itself and the number 1, such as 1, 3, 5, 7, 17, 101 and 10007...
For a moment, Li Yan seemed to see the confidence of the teacher who set the question. expression. From the beginning, it seems that the difficulty of the questions should be raised to a higher level.
“Enter a set of words, each word consisting of letters a-z. Each letter corresponds to a specific value, the letter a corresponds to 1, b corresponds to 2, and so on.
If If the sum of the letters of a word is a prime number, then the word is a prime word (primeworld). Please write a program to determine whether a word is a prime word.
If the sum of the letters of a word is a prime number, output Itisaprimeword, and vice versa. Then output Itisnotaprimeword”
Li Yan actually had an idea right away. The length of words is limited and the corresponding numbers are limited. He can calculate an upper limit number, then filter out the prime numbers in the range to make a set u, and then directly use the formula to calculate the numbers and x corresponding to the letters of the word. Directly compare the result with the set of prime numbers. If the result is u[x]=1, the Itisaprimeword will be output. Vice versa, the problem will be solved.
In Li Yan’s view, the calculation with formulas is not the real difficulty of this question. The real test is the screening of prime numbers.
You know, the English word for "pneumoconiosis caused by inhaling silicate fines or quartzite ash" is pneumonoultramicyoscpicailicovolcanoconiosis, which has 45 letters.
This is not necessarily the longest, it is just the longest word that Li Yan knows. Even if we take the average of 13, for a 50-letter word, the upper limit will be 650.
This prime number is not easy to filter...
No, that's not the problem. If you don't know where the upper limit is, what if there are 1,913 letters in the world?
Who knows what some professional terms will turn out to be, so does this prime number screening still need to be calculated to 20,000?
This level of difficulty is no joke.
In an instant, Li Yan realized something was wrong. This was not the most difficult two-person cooperation problem. He, the all-powerful God of War, was hesitant about the problem. Others were playing snake?
He pushed the mouse wheel in a strange way:
"The input gives a set of words. The letters of the words are randomly composed. Each word is on a line. The number of letters does not exceed 20."
Holy shit... He almost dug his hands into the keyboard for a moment. No matter how he looked at the question, it looked like It’s over, why did this line of work get hidden!
No more than 20, given randomly, that is, the upper limit value does not exceed 520, you only need to filter the prime numbers between 1 and 520.
How to sift? Hard screen.
Li Yan memorized the set of prime numbers from 1 to 300. After excluding some obvious composite numbers, there was not much left to calculate.
Damn it, if I had known it would be 1,000, wouldn't I just be killing people indiscriminately now?
A question that was not too difficult made Li Yan feel nervous. As soon as he finished the screening set of prime numbers, he started to construct the formula non-stop.
In the end, he didn’t even check it and clicked submit the moment he finished writing the program.
Ding dong!
"The first place to complete the second stage questions: B-7, New Taipei Middle School, Deng Yudi, time 34:41" "The second place to complete the second stage questions: E-12, New Taipei No. 1 Middle School, Li Yan, time 36:54”
What the hell? The whole place was agitated. Some people had just started to enter the second stage. How come two of them had completed the second stage?
Isn’t this New Taipei No. 1 Middle School a junior high school? What are junior high school students pretending to be... Then they saw clearly that the name was Li Yan, are you serious?
The young woman next to Director Jin, Vice Chairman Zhang of the Linjiang Provincial Computer Association, was a little surprised, "The two stages of the four and a half hour exam only took one hour? Isn't that too exaggerated? ?”
“Exceeding expectations, isn’t it great?” Director Jin said with a smile.
But he was actually not very good at heart. If Li Yan ended up just trying to please others, he would lose face.
Li Yan in the audience was a little shocked. Deng Yudi started the questions in the second stage a little slower than him. Even if he didn't read all the questions at the beginning and wasted a little time, Deng Yudi at least spent the same time as him. Time solves the two-stage problem.
Li Yan is very confident that his hand speed cannot match that of Deng Yudi, so Li Yan should be faster on basic questions.
How come this Deng Yudi is faster than Li Yan who memorizes prime numbers between 1 and 300 in the second question?
Two possibilities, one is that Deng Yudi memorized prime numbers between 1 and 520; the other is that this guy directly wrote a program to screen prime numbers - and it is very efficient.
No matter what the possibility is, this guy is indeed a ruthless character...
But now it’s time to focus on the third stage, which is the cooperation question. This question will undoubtedly be the most difficult today - or The workload is the largest, but Chen Fan hasn’t finished it yet. Li Yan can only figure it out by himself for the time being:
“Given several line segments of a straight line, the straight line is the X-axis, and the coordinates of the line segments are [Li, Ri]. Find What is the minimum number of line segments needed to cover the interval [0, m]?”
Li Yan frowned slightly, this question didn’t seem right.
“The first line of input gives the number of test cases, followed by a blank line.
Each test case first gives an integer M (M is less than or equal to 5000 and is greater than or equal to 1), followed by several lines, each line using 'LiRi' to represent the line segment..."
"Output: For each test case , the first line of output is a number, indicating the minimum number of line segments covering the interval [0, m]. The next few lines represent the selected line segments, giving the coordinates of the line segments, sorted by the left end. If there is no solution, that is, [0, m] cannot be covered by the given line segment, then output 0..."
The difficulty is indeed there. Li Yan did not start immediately after reading the question. If this type of question is If a bug is fixed in a hurry, the time cost of repairing the program will be higher.
There must be a complete and feasible idea first.
The big screen also has a second stage. Completed by:
"The third place to complete the second stage question: E-11, New Taipei No. 1 Middle School, Chen Fan, time 45:02"
45 minutes? He was not only a few minutes late, it seemed that Chen Fan spent a lot of time answering the written test questions.
But yes, "fast" is not the main requirement for this exam.
"Li Yan?" Chen Fan's voice came from the earphones.
"Received."
"Why are you so fast? That Deng Yudi is also crazy, everyone is so fast, there is no need!"
Indeed, although the last question is difficult, three hours is enough, based on ensuring the accuracy. , on top of this, improving the excitement of your ideas is the most important thing.
Li Yan just wanted to show off, but she just didn’t know what Deng Yudi was about.
"Aren't you pretty fast? You made it to the top three in the second stage." Li Yan was indeed surprised. Chen Fan had never used speed as his advantage, but he could actually win at the high school home court where there were many strong opponents. Next showcase.
“Oh, I memorized the prime numbers between 0 and 600, which saved me a lot of effort on the previous question.”
you?
If you want to complain, let’s just take a look at the questions.
“You should become famous early, Chen Fan.”
(End of this chapter)