Problem:
A sequence of s and s is called antipalindromic if writing it backwards, then turning all the s into s and vice versa, produces the original sequence. For example is antipalindromic. For any sequence of s and s we define the cost of the sequence to be the product of the positions of the s. For example, the string has cost . Find the sum of the costs of all antipalindromic sequences of length 2020.
Solutions — 3
Solution 1
Solution:
For each integer define a -pal to be any sequence of 2020 s and s, where the first terms are , the last terms are , and the middle terms form an antipalindromic sequence.
Now for any , define to be sum of the costs of all -pals. Note that any -pal can be created from a -pal by either
- (A) replacing the in position with an , or
- (B) replacing the in position with an .
Therefore the sum of the costs of all -pals formed using operation (A) is . Similarly the sum of the costs of all -pals formed using operation (B) is . Hence
Now we note that there are two different 1009-pals, with costs equal to 1010 and 1011 respectively. So
Now if we use the formula iteratively, we get for each . Therefore
which is our final answer.
Solution 2
Solution:
Let be a positive integer. We will find an expression (in terms of ) for the sum of the costs of all antipalindromes of length . Note that a string of s and s of length is an antipalindrome if and only if for each , exactly one of the and letters is an (and the other is a ).
Let be variables. For any , consider the string of s and s of length , such that the letter is for all (and all the other letters are ). Let this string correspond to the term . If for all then the value of is equal to the cost of its corresponding string. Now consider the expression
If we expand the brackets then we get terms, each in the form such that for each either or . Therefore is the sum of all terms that correspond to antipalindromes. Hence if we substitute for all , then the value of would be the sum of the costs of all antipalindromes. So the final answer is:
Solution 3
Solution:
Let be a positive integer. We will find an expression (in terms of ) for the sum of the costs of all antipalindromes of length . Let denote the set of all antipalindromes of length , and let be an antipalindrome chosen uniformly from . Note that for each the and must be an and a in some order. Let be the random variable defined by:
if the letter of is an and the letter is a
if the letter of is a and the letter is an
Notice that the cost of is given by the product . Now consider to be the function which swaps the and letters of the string. Notice that is a bijection that toggles the value of . This means that is equal to or with equal probabilities. Therefore
Furthermore preserves the value of for all . Therefore the variables and are independent. Therefore the expected value of the cost of is given by:
Now the number of antipalindromes of length is simply (one for each choice of the variables ). Therefore the sum of the costs of all antipalindromes of length is simply multiplied by the expected value of the cost of . This is