Personal thoughts on the topic of the 10th Blue Bridge Cup Group B in 2019

Fill in the blank

For the first question, violence and dfs are okay, 20^5, be careful not to have more than two positions with a person, the answer is 490, and the five people are 97, 99, 98, 98, 98;

The second question is to convert from decimal to 26. It feels strange to not find a value to represent 0, but the impact is not very big. The answer is BYQ in the violent calculation, so I don’t care.

第三题,dp[i] = (dp[i-1] + dp[i-2] + dp[i-3]) % 10000;

For the fourth question, the sum is three different numbers of 2019 and the number of schemes 2 and 4 does not appear. Still violence, in order not to repeat, I enumerate a∈[2019/3,2017], b∈[1,a), and then c is 2019-ab. When c<b&&c>0 and three numbers meet the requirements of the title, the solution Count ++ and calculate the answer 40785;

For the fifth question, it seems that there is only one kind of emm solution, so dfs also works.
I used bfs+ to record the path, and it seems to be the same as the 186 mentioned by the big guys. .

Procedural questions

The sixth question, judge the number of bits, add it up, and the next question;

The seventh question, complete binary tree, and in order, explain n=2^k-1, then for i ∈ [1,k], x ∈ [2 to the (i-1) power, 2 to the i power -1 ] Is one level, add it up and judge the result, two points of attention: ①The answer may be negative ②Long long is required;

The eighth question, the two cases
①If all are the same, output n; (this is not the case in the game);
②If there are differences, it is a normal arithmetic sequence, sorted in order, calculate the difference between adjacent terms, and take gcd Yes, number of items = (last item-first item)/tolerance+1;

For the ninth question, the meaning of the question is not understandable. There are various kinds of opinions. Just talk about your own ideas, sort them, subtract the number of m, add up the following numbers, OK, the example is over. That's it.

The tenth question, the meaning of the question is to give you n numbers. You can perform an unlimited number of operations. The operation is to take an i∈[2,n-1], make both sides of i +ai, then ai-=2ai, ask the absolute value of the final sequence What is the largest and smallest number?
(personal idea)

First translate a sentence, ai-=2ai <=> ai = -ai;
data range ai∈[0,1e9], n range 3e5, indicating that the worst time complexity is also nlogn, which can be associated with a binary answer, but we need Checked in O(n) time.

To check, you must first calculate a few mathematical things:
set the result of the binary answer mid, suppose the absolute value of Ai is greater than mid, then now we have to solve the problem of Ai, and then assume that the absolute value of Ai should be reduced from the positive direction (the reverse direction is similar ), there are the following two methods:
①If sgn(Ai+1) = -sgn(Ai), you can operate Ai+1 once;
②If sgn(Ai+1 + Ai+2) = -sgn(Ai) , You can operate Ai+1, Ai+2, Ai+1, I will not introduce the specific simplification process in detail, after the change, Ai~Ai+3 will become the following conditions;

Ai Ai + 1 Ai + 2 Ai + 3
Ai + Ai + 1 + Ai + 2 -Ai + 2 -Ai + 1 Ai + Ai + 3 + 1 + Ai + 2

For the above two methods, we can find that if we do it again in the same way, we can eliminate the transformation, which is helpful for us to make corrections (more on that later).

The above, at least in my opinion, can already cover the one-way modification method. There may be some questions, but I answer one by one:
Ⅰ. After such modification, it seems that there are other situations, such as the case of ②. Modifying Ai+1 is a new situation at this time, why not consider it?
After you modify it, Ai will become smaller again. I am currently just to better solve the Ai problem. After solving the problem of Ai whose absolute value is too large, you can push back the impact and then consider the following problems. This also involves the reason why I think this method may be feasible. If the current direction fails to solve the problem, it means that the current direction alone cannot solve the problem. You can only modify it in the opposite direction. If the modification fails in the opposite direction, then there is no solution ;
Ⅱ. After typing the last question, forget it, forget it, think of it, and try again or if you have any questions about this article, please chat with me privately;

The official problem solution has not yet come out, so let's assume that the method is feasible:
Ⅰ. From the operation steps, the steps of ② include ①, you can judge ① first, then judge ②;
Ⅱ. How to achieve it, my method is to sweep in the direction first Go over it again, so that there are values ​​that cannot be eliminated in the positive direction (including the end), and then scan it again in the opposite direction. If those values ​​still cannot be eliminated at this time, it means that there is no solution. Otherwise, all values ​​are reached, then success.

If the above method is reasonable, it means that O(n) check is possible. Of course, it may be necessary to solve the problem of constants. After all, I feel that the evaluation machine is not good.

The code, in the examination room,,,, I don’t know what to do, so let Ben Konjac get out of the question while the solution is still out hh

If you need to reprint, please privately chat with the blogger. Thank you. Please indicate the source of the reprinted content.

Guess you like

Origin blog.csdn.net/aiqiyizz/article/details/88785244