-
Why they are taken in this way, and why x is from 1 to 14, this needs to be carefully calculated. Because the amount of calculation in this problem is very small, sometimes I try to save my own effort (calculate a little less) and let the computer calculate a little more.
Because x is at least 1, and y>x, z>y, for simplicity, and the unit prices of x, y, and z are a, b, and c, respectively, so ax+by+cz=800
And ax+by+cz>ax+bx+cx
So, 800>(a+b+c)x
x<800 (30+20+10), i.e. x<=13 (rounded) In the same way, the minimum y is 2,800=30+20y+10z>30+20y+10y, and the maximum y=770 30=25
-
In fact, it is clear that the range sought in the first diagram is not optimal; If you want to optimize, it's about narrowing it down step by step.
At least based on the known conditions, it can be narrowed down to the following.
1 <=x <=14
2 <=y <=21
16 <=z <=42;
If you write it in C, it will look like this:
#include
int main()
int x, y, z;
for(x = 1; x <=14; x++)for(y = x + 1; y <=21; y++)z = 45 - x - y;
if(z >
printf("x = d, y = d, z = d", x, y, z);
return 0;
-
The impoverishment of an algorithm means that the running time of an algorithmic program is limited.
The adaptability of the algorithm means that the running time of the algorithm program is limited. The algorithm must be completed within a limited time, i.e. the algorithm must be able to terminate after performing a liquidation limit step.
In principle, the algorithm can be run precisely, and it can be done with a limited number of calculations with a pen and paper. Infinity means that the time for the algorithm program to operate wisely is limited.
The basic characteristics of the algorithm mainly include the following four aspects:
1. Feasibility: The algorithm designed for practical problems can get satisfactory results after implementation.
2. Determinism: Each step in the algorithm must be clearly defined, and ambiguous interpretations and ambiguities are not allowed.
3. Infinite: The algorithm must be completed within a limited time, that is, the algorithm must be able to terminate after a limited number of steps.
4. Have enough intelligence: In order for the algorithm to be effective, it is necessary to provide enough information for the algorithm, and the algorithm is the most effective when the algorithm has enough intelligence; And when the intelligence provided is insufficient, the algorithm may not be effective.
-
The steps of the algorithm are limited, that is, after a certain amount of time, the algorithm can be completed.
-
Poorness, simply understood, means that there is an end. Such as for loops.
The first one is poor:
for(int m=1;m<=3987;m++) the second is infinite:
for(int m=4;m>3;m++)
That's an infinite loop. It never ends. I can't stand it.
-
The running time of an algorithmic program is limited. (I just got this question wrong.,This is the standard answer.,I'm looking for an explanation on the Internet.。。。 Hehe. )
-
After a limited number of steps, it ends.
-
It means that it will not be executed forever and cannot be ended.
-
It means that the running time of the algorithm program is limited!
-
The algorithm does not go into an endless loop and ends eventually.
-
Inexhaustible: An algorithm must be guaranteed to end after executing a finite number of steps.
Feasibility: The algorithm can be run precisely in principle, and can be done with a limited number of calculations with pen and paper.
There is impoverishment (finiteness). Any proposed solution can be done in a limited number of steps, "even if it is a failed solution." ”
-
Can be stopped after a limited number of steps.
-
a) The running time of the algorithm program is limited.
-
a) The algorithm must be completed within a limited time, i.e. the algorithm must be able to terminate after a finite number of steps.
-
b) The amount of data processed by an algorithmic program is limited.
-
Answer C analysis: The so-called infiniteness of the algorithm means that an algorithm should contain a limited number of operation steps, that is, the algorithm is terminated after a finite operation is performed, so that conclusions can be obtained
Answer: An algorithm must end in a finite step, simply put, there is no loop.
i.e. the steps of the algorithm must be limited.
-
Answer: The infinity of algorithm C means that the sequence of steps of an algorithm is finite, and it should stop after a finite step, and cannot be an imitation of careless sail limits.
-
The exhaustive method is used when the data is out of order or there is no good way to filter by listing all the possible answers. Typical programming beginner problems applicable to the exhaustive method include: the 100-chicken problem, sequential search, brute-force cracking of passwords, etc.
The idea of the exhaustive method is to list all possible situations and judge which ones meet the requirements of the problem one by one, so as to obtain the answer to the problem. It is used to solve types of questions such as "whether there is" and "how many possibilities" exist.
The exhaustive method is generally implemented with a loop or a nested structure of loops, and it is necessary to pay attention to the beginning and end points of the loop, and not to omit possible situations, and generally not to repeat.
1. The basic idea of the exhaustive method is to list the possible situations involved in the problem one by one, and make judgments one by one according to the conditions and actual background of the topic, and select the answers that meet the requirements.
3. The exhaustive structure is generally used in a circular structure, and it is necessary to pay attention to the beginning and end points of the cycle, and the possible situations cannot be omitted, and generally should not be repeated.
4. When compiling the program, it should also accurately write the judgment statement of whether it meets the requirements of the topic.
Understand the following rules: 1) Overloading an operator does not change the priority of the operator. >>>More
do is used to loop.
For example. int i=1,sum=0; >>>More
Define the struct:
typedef struct _legaladdress_{ >>>More
A local variable (an internal variable) is defined inside a function, and its scope is limited to the variable inside the function that defines it. >>>More
Just take a look at this one**.
Hope it helps. >>>More