Editorial for DMOPC '21 Contest 4 P3 - Palindromic Presents
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
We give some possible constructions worth varying amounts of points.
Intuitively, we do not want any "carries" to occur when adding a subset of the palindromes, as it is much harder to ensure that the sum remains a palindrome after some carries. This encourages us to use many small digits in the construction. We would also like all our numbers (except for a ) to have the same number of digits, so that the same digits "interact" with each other when adding up any subset. To avoid carries from the most significant digits, we can make all of them a . Trying to place some other digits on different place values, we might find a construction like:
0
11000000011
12000000021
10100000101
10200000201
10010001001
10020002001
10001010001
10002020001
10000100001
This and other constructions with are given of the points.
Note that we can have one number contain all 's between the least and most significant digits. Doing this, we might get something like:
0
110000011
120000021
101000101
102000201
100101001
100202001
100010001
100020001
100000001
This and other constructions with are given of the points.
We can use the digit as well before would result in a carry. Doing this, we might get something like:
0
1100011
1200021
1300031
1010101
1020201
1030301
1001001
1002001
1003001
This and other constructions with are given of the points. Constructions with are given of the points.
To do better than digits for each number, we need to consider numbers with more than nonzero digits. As we need the nonzero numbers in our set to be distinct while using small digits, we might try representing numbers in base , giving something like:
0
10001
10101
10201
11011
11111
11211
12021
12121
12221
This construction works perfectly, as happens to be a power of , giving with no carries. This and other constructions with are given of the points. Constructions with are given of the points.
To optimize further, we might try using the digit as well to give us more freedom to choose the numbers. Trying some combinations of numbers, we might find:
0
10001
10101
10201
10301
11011
11111
12021
12121
13031
With . This is given of the points.
As we want to minimize the more significant digits, we can swap the thousands and hundreds digits of everything to get:
0
10001
10101
10201
10301
11011
11111
11211
12021
13031
With . This turns out to be the minimum possible and is given of the points.
Remark 1: We can verify using recursive backtracking that it is impossible to obtain a smaller . In fact, another way to approach this problem is to write a recursive backtracking program to help find the construction above for us.
Remark 2: The above construction with is unique, up to reordering the elements.
Remark 3: We can prove that there does not exist a set of or more non-negative integers with this property by showing that some subset of the nonzero numbers (say ) will sum to a multiple of . This claim follows from that some two of the prefix sums are the same modulo by Pigeonhole, so their difference corresponds to a subset that sums to a multiple of .
Comments