620A - Робот профессора GukiZ
Easy to see that the answer is max(|x1 - x2|, |y1 - y2|).
Complexity: O(1).
620B - Калькулятор дедушки Довлета
Let's simply iterate over all the values from a to b and add to the answer the number of segments of the current value x. To count the number of segments we should iterate over all the digits of the number x and add to the answer the number of segments of the current digit d. These values can be calculated by the image from the problem statement and stored in some array in code.
Complexity: O((b - a)logb).
620C - Жемчужинки
Let's solve the problem greedily. Let's make the first segment by adding elements until the segment will be good. After that let's make the second segment in the same way and so on. If we couldn't make any good segment then the answer is - 1. Otherwise let's add all uncovered elements at the end to the last segment. Easy to prove that our construction is optimal: consider the first two segments of the optimal answer, obviously we can extend the second segment until the first segment will be equal to the first segment in our construction.
Complexity: O(nlogn).