Algorithms are a way of thinking.
Background
My understanding of algorithms during this period comes down to one sentence
Make bold assumptions and verify them carefully, right?
At first, my earliest concept of algorithms was Greedy algorithms
The description of Greedy algorithms
Baidu Baike says this
A Greedy algorithm (also called a greedy algorithm) means that when solving a problem, it always makes the choice that looks best at the moment. In other words, it does not consider overall optimality; what it makes is a locally optimal solution in some sense.
A Greedy algorithm does not yield the global optimum for every problem. The key is the choice of greedy strategy, which must have no aftereffect—i.e., the process before a certain state does not affect later states and is related only to the current state.
At the time, I only half-understood this explanation (and I still seem to now)
So I could never get a clear answer to what an algorithm really is
Before I figured it out
I felt the payoff from solving problems was a bit low
Problem link: HPU Class of 2015 Individual Contest - Virtual Judge (hpuacm)
And this individual contest had eight problems
I forgot to save the code after it ended
And I felt there was no need to look for submission records on the website
So for the code of these problems
I should upload a rewritten version
The eight problems are:

I won’t screenshot them one by one
I’ll organize them slowly later
This article will just briefly talk about them from the perspective of problem-solving ideas
Problem A Interest Calculation :
As a pure mathematical calculation problem
To some extent it tests control over data types and input/output
But for this kind of problem, as a sign-in problem itself
I think the more important purpose is to get myself into the right mindset
So that I won’t panic in the following problems
And in this contest I made exactly this mistake
Without thinking about a bunch of numbers, I chose to do Problem B first
However…
Problem B - 18th Birthday :
The source of my nightmare in this individual contest
Another problem about leap years
From this problem
I learned for the first time that leap years are not strictly once every four years
A tropical year is not 365 days, but 365 days, 5 hours, 48 minutes and 46 seconds. The extra time accumulates, and the new year shifts later, so every four years a leap year is set, and February in that year becomes 29 days. Thus a leap year has 366 days. However, this way every hundred years there is about one extra day, so it is also stipulated that “century years” are not leap years, i.e., “24 leap years per century.” But deducting one leap day per century is still not exact, so it is further stipulated that years whose AD year number is a multiple of 400 are leap years.
I had always thought that 1900 not being a leap year was a mathematical problem
That is, 1988 and 1902 are both leap years (actually they are not)
But through this lesson I learned something
At the same time, more deeply
It was also a lesson for myself
I was too confident
That is, I trusted too much that I knew what the problem setter was thinking
(Not necessarily divisible by 4; those divisible by 100 also need to be divisible by 400)
Normally, this way of thinking would be enough for ordinary problems
However, the method I used for this problem
Exactly used the idea of one leap year every four years
(This idea is wrong)
See the solution article for the specific solution discussion
Problem C - Magic Spheres
This problem also had mysterious WA
I couldn’t figure out all kinds of cases
Then I found a sentence…
he needs at least x blue, y violet and z orange spheres.
The key point is…
at least
That is, the data above does not need to be exactly equal to the data below
As long as the above can be changed into something greater than or equal to the below, that’s fine
However, all the two sets of Yes data given
satisfied being equal to the below
So this led to a misunderstanding of the problem…
Thinking about the reason
It’s that for this kind of English problem
I generally guess the meaning of the problem by comparing the input and output
So this led to a preconceived idea
This is also something to be vigilant about when facing English in the future
Problem D - The Best Gift
The magical thing about this problem is
I actually ACed it smoothly without using the m given in the problem -.-
Problem E - Red and Black
This is a classic search problem
Problem F - Load Balancing
Load balancing, an algorithm for sequence balancing
At that time, because I had spent too long on the previous problems
I didn’t even have time to look at this problem…
(Mainly because I saw many others got WA, so I didn’t write it)
Problem G - The Suspects
According to the problem statement, it should be Union-Find
But at first glance my idea was to go toward search
In the end I solved it too
Problem H - Networking
A Minimum Spanning Tree problem
I had done similar ones before
Reflection
After these eight problems
I was actually thinking about what an algorithm really is
If it is only a method of solving problems
I think that seems inappropriate
For example, some problems such as
Problem G - The Suspects
belong to simple Union-Find
But if search is used, it is not hard to understand either
Or
Problem E - Red and Black
belongs to search, but both bfs and dfs can solve it
So what is an algorithm
I think reducing algorithms to a kind of problem-solving thinking
may be more appropriate
That is, there is no need to regard an algorithm as a template, but as an approach to solving problems
What is the difference
I think it is whether, when judging that a problem looks like a problem for some algorithm
the first thing that comes to mind is the algorithm’s idea or the algorithm’s code framework
I think a better situation is to understand the essence of the algorithm
Then no matter how the problems change, you can always find the key to solving them
Without struggling over which template it fits
Algorithms are a way of thinking
This is my current understanding of algorithms
Let me follow this path for now
And then slowly correct my views
Moreover
No matter how you understand it
You still need to study an algorithm seriously
Or even study it harder
Explore some things about its essence
By the way, recently I seem to have developed
the habit of writing an article over several days -.-
Sometimes it seems to affect my train of thought~
Hahaha
I should try to finish it in one go as much as possible~
Appropriate additions are still okay