A. Elections

Solution:

Calculate the difference between the maximum number of votes of the other two people and add one.

Java

C++

B. Make it Divisible by 25

Solution:

The characteristic of a number divisible by 25 is that there are only 4 possibilities for the last two digits: 00, 25, 50, 75. So we can look for these four possibilities from back to front.

Java

C++

C. Save More Mice

Solution:

Because the time for the cat to reach the hole is fixed, we only need to save as many mice as possible within a limited time. The time it takes to save a mouse is directly related to the distance between the mouse and the hole at the beginning.

Therefore, we sort directly according to the distance to the hole, and save from the shortest distance.

Java

C++

D. All are Same/Half of Same

D1's approach is not difficult to think of. The key to comparing D2 with D1 is to find out that all factors can be obtained through brute force.

E. Gardener and Tree

Solution:

Topological sorting, the only difference is that two queues are needed to count the number of operation times.

Java

C++

F. Red-Black Number

Obviously a DP problem, the key is to find the 4 key states in the problem: the first i numbers, the difference between the number of red and black, the remainder of dividing by A and dividing by B.

G. Changing Brackets

The key to this problem is to find out the influence of the parity of brackets on the results.