Chapter 100 Contestant No. 101 Submits Papers Early?

Compared with Academician Zhan Yongshu's surprise, Hao Yun didn't think about it as complicated when he thought about this problem, and he came up with this method purely on the spur of the moment when he scratched his head.

The program first guesses a value close to 1/sqrt(number) and then uses Newton's iterative formula to perform iterative operations.

From the perspective of algorithm logic alone, in fact, the code he rewrote is not much different from the code of the previous Q_Sqrt function. The Q_Sqrt function defined by Glacier Engine in the math.c file actually follows this idea.

And if there is any difference, it is probably in that mysterious number - 0x5f375a86.

According to the principle of Newton's iterative algorithm, the closer the guessed value is to the final result, the fewer iterations there are. And the mysterious number 0x5f375a86 is used to calculate the guess value.

After trying a few times, Hao Yun unexpectedly found that if he used the number "0x5f375a86", the obtained y would be very close to 1/sqrt(n), so that when he finally executed Newton's iterative algorithm, he only needed 2 algebras to achieve the accuracy he needed!

As for how did you come up with this number?

Hao Yun couldn't explain it.

After all, he just followed his mathematical instincts, felt that the numbers selected in the original program were not good enough, and then tried to try a better number.

At first, he tried several times and found that the changed numbers were not as good as the original number, until he got the 0x5f375a86 and found that it only took two iterations to complete the entire calculation process.

To be honest, he himself was surprised.

Possible......

This also has something to do with his math attributes reaching mastery?

All in all, with the special number of 0x5f375a86, the whole function will be twice as efficient as the Q_Sqrt function defined in the original math.c file in terms of the number of steps!

As for what kind of effect this result will have......

To be honest, Hao Yun doesn't have an accurate concept either.

After all, his knowledge of this glacier engine is far from reaching the height of industry insiders.

Although he has made games before, he has only made the game 2048. Temple Escape is a development software with the same origin as the glacier engine, but that game was basically completed by Li Zongzheng alone, and Hao Yun did not participate in the development process at all, and even if he participated, he would not study the source code of the engine.

The game development tools in this world have evolved to the point of foolishness enough, and with the exception of the big productions, the vast majority of small and medium-sized games can be achieved by relying solely on development tools and a level 2 programming level.

β€œβ€¦β€¦ After all, how much has the efficiency of the test engine improved? Don't you have a scoring software or a test game on your computer? ”

Hao Yun searched carefully on the computer, but he didn't find any kind of tools that could be used to score the engine, nor did he find a game that could test the performance of the engine.

In fact, the organizers really didn't prepare such a thing.

After all, from the very beginning, they never thought that anyone could really complete this proposition.

"I'll go, this is wool?"

After some searching, he still didn't find the detection tool, Hao Yun looked at the screen with a smile and a smile, completely out of line.

You can't develop a game on the spot to run scores, right?

It's not impossible, but I don't have any materials at hand, and the computer can't be connected to the Internet, so I can't start with the most basic materials, right?

After some struggle, Hao Yun finally gave up.

Never mind.

I can't think of a better way to optimize it anyway......

Thinking so, Hao Yun sighed, reached out and clicked on the submit option in the exam process, and then left the keyboard with both handsβ€”the so-called AK.

The maximum time limit for the exam is only set for three days, and there is no minimum time for handing in the papers, and you can leave the venue at any time after submitting your answers.

Because even if you submit the paper early, you will not get extra points, so even if you finish it early, you will choose to stay up until the meal and then hand in the paper, and go out to eat with friends who come to the competition together.

Hao Yun also planned to do so at the beginning, but there was nothing in his cubicle, there was nothing to do except sit and wait, so he could only come out of his cubicle.

When I left the examination room, it was the same security guy standing at the security checkpoint.

Hao Yun glanced at him, and he also stared at Hao Yun for a while.

"Going to the toilet? You're going in the wrong direction. ”

"No, I'm done."

"Exam, finished exam?"

"Well," Hao Yun nodded and pointed to the exit of the gymnasium, "Can I go out?" ”

Finally came back to his senses from his stunned state, and the security guard brother Mumu nodded and untied the barrier at the entrance.

Two years ago, the Hope Cup was also played at Xiadong Normal University, and he was also standing here to maintain order at that time. If he remembers correctly, the earliest candidates to submit their papers at that time were also at five o'clock in the afternoon.

Now, however, it is not an hour before the official start of the exam at nine o'clock......

Is this a blank slate?

Anyway, he is also the finalist who has been shortlisted from tens of thousands of works, so he won't hand in a blank paper, right?!

In fact, it wasn't just a few security guards standing at the entrance of the exam room who were surprised.

The presiding examination committee standing in the background of the examination room was far more astonished than everyone here.

Especially Professor Zhang Cunhao.

After reading the code rewritten by Hao Yun, the whole person was stupid.

Staring at the dense calculations on the scratch paper, Professor Zhang Cunhao, who had calculated countless times without believing in evil, finally couldn't help but burst into a foul mouth.

"! This guy ...... How did you come up with this number? ”

This......

It's incredible!

Just changing the guess number makes the entire function twice as efficient?!

Standing next to Professor Zhang Cunhao, Feng Zhengqing, manager of the software development department of Longwei Group, quietly pulled him and asked in a low voice, "How much can it improve the operating efficiency if it is applied to the glacier engine?" ”

"According to a conservative estimate of 20 percent, there are still a lot of operations related to the inverse square reciprocal in the 3D engine......"

"How can there be so many?" Manager Feng was slightly moved.

As a layman, he doesn't know so many ways, and he doesn't understand what Newton's iterative algorithm is, but he thinks it's incredible!

Although the glacier engine is not the core R&D project of Longwei Group, there are definitely many computer experts in the project team. However, so many people did not find this improvement method, but it was discovered by a student?

I can't believe anyone else!

Filled with scratch paper, Professor Zhang Cunhao threw it in deep thought, although he had gradually felt that this thing was beyond the field of research he was familiar with.

Standing next to him was an old professor from the National Defense University in the capital, and after being silent for a long time, the old professor also let out a heartfelt sigh.

"Incredible...... I didn't expect this guy to find a breakthrough in the most unlikely place. I always thought that the functions in the math.c file were perfect enough to be used directly like addition, subtraction, multiplication, and division. I didn't expect that there would be such a magical way to make the perfect boundary go one step further. ”

"This kid is a talent!"

I don't know what I'm thinking in my heart, Professor Zhang Cunhao's silent expression suddenly has a trace of entanglement.

After struggling for a long time, he looked at his teacher, Academician Zhan Yongshu.

"But with all due respect, is that really okay?"

Academician Zhan Yongshu glanced at him.

"Are you still not convinced?"

"I'm not unconvinced, I just think...... It's a little aggrieved," Professor Zhang Cunhao held back for a long time before he said what was in his heart, "This is not a solution in the sense of the program at all, and he didn't even modify even a line of code at all." Anyone can see it...... That's math! ”

Yes, it's all about math!

The contestant just changed a random number, and as a result, it happened that the underlying function of calculating the "inverse square reciprocal" did a few fewer Newtonian iterations, and then "added up" to the optimization of the engine?

Why is this number after all?!

After all, he is not a mathematician, Zhang Cunhao was about to collapse when he thought about it, and he didn't come up with it.

Looking at the frantic student, Academician Zhan Yongshu suddenly smiled.

"Who's to say it isn't?"

He didn't know how this number was calculated, and he didn't have a clue at all.

Relying solely on intuition?

Similar situations are not uncommon, and some mathematical constants are actually guessed by experience at the beginning, and the mathematical principles are not proven until more than ten years or even centuries later.

Thinking of this, looking at the candidate who was leaving the examination room, Academician Zhan Yongshu couldn't help but sigh softly in his heart.

Possible......

That's genius, isn't it?