Maths Olympiad Prep

Library / /34 of 36

Combinatorics Difficulty 7.5 National Olympiad, round 2 Prove it Italy

Problem:

A sequence x1,x2,,xn,x_{1}, x_{2}, \ldots, x_{n}, \ldots consists of an initial block of pp distinct positive integers, which then repeat periodically. This means that {x1,x2,,xp}\left\{x_{1}, x_{2}, \ldots, x_{p}\right\} are pp distinct positive integers, and xn+p=xnx_{n+p}=x_{n} for every positive integer nn.
The terms of the sequence are not known, and the goal is to determine the period pp. To do this, at each step one may reveal the value of a term of the sequence of one's own choosing (and the choice may depend on the outcome of the previous steps).

a. Knowing beforehand that 1p101 \leq p \leq 10, determine the minimum nn for which there exists a strategy that allows one to determine pp with certainty by revealing at most nn terms.

b. Knowing beforehand that pp is one of the first kk prime numbers, determine for which values of kk there exists a strategy that allows one to determine pp with certainty by revealing at most 5 terms.

Solution

Solution:

We divide the proof into 3 parts: first we exhibit a strategy in four steps for part (a), then we exhibit a strategy in five steps for part (b) with k52k \leq 52, and finally we show the optimality of the number of steps of these strategies.

Strategy for part (a)

A possible strategy consists of revealing the following four terms of the sequence: x1000,x1004,x1010,x1045x_{1000}, x_{1004}, x_{1010}, x_{1045} (or in general xa,xa+4,xa+10,xa+45x_{a}, x_{a+4}, x_{a+10}, x_{a+45}).

To show this, let us call pp the period, and observe that xi=xjx_{i}=x_{j} if and only if pp divides jij-i (at this point it is crucial to know that the pp terms that repeat periodically are all distinct from one another). Consequently, depending on the value of pp between 1 and 10, we will have all and only the identities among the revealed numbers indicated in the following table.

PeriodIdentitiesPeriodIdentities
1x1000=x1004=x1010=x1045x_{1000}=x_{1004}=x_{1010}=x_{1045}6x1004=x1010x_{1004}=x_{1010}
2x1000=x1004=x1010x_{1000}=x_{1004}=x_{1010}7x1010=x1045x_{1010}=x_{1045}
3x1000=x1045,x1004=x1010x_{1000}=x_{1045}, x_{1004}=x_{1010}8no identity
4x1000=x1004x_{1000}=x_{1004}9x1000=x1045x_{1000}=x_{1045}
5x1000=x1010=x1045x_{1000}=x_{1010}=x_{1045}10x1000=x1010x_{1000}=x_{1010}

From the table it follows that it is possible to uniquely determine the period depending on which identities are observed.

Strategy for part (b)

It suffices to exhibit a strategy that allows one to distinguish among the first 52 prime periods: the same strategy will, a fortiori, distinguish among the first k52k \leq 52 primes.

To describe a possible strategy, let p1,,p52p_{1}, \ldots, p_{52} be the first 52 prime numbers, and let PP be their product. Now consider the set S={1,2,3,4,5}S=\{1,2,3,4,5\}, and define a partition of SS as any way of dividing this set into nonempty subsets. For example, {{1,2},{4},{3,5}}\{\{1,2\},\{4\},\{3,5\}\} is a partition of SS (it is understood that the order in which the subsets {1,2},{4},{3,5}\{1,2\},\{4\},\{3,5\} are presented is irrelevant in this notation).

We will show below that the set SS admits exactly 52 partitions. Let us number these partitions in some way from 1 to 52, in such a way that the first one is the one consisting of the single subset SS, and the second one is {{1},{2,3,4,5}}\{\{1\},\{2,3,4,5\}\}. For every integer ii between 1 and 52, consider the function fi:SSf_{i}: S \rightarrow S that associates to every element xSx \in S the smallest ySy \in S that belongs to the same subset as xx in the ii-th partition. For example, if the 42nd partition were {{1,2},{4},{3,5}}\{\{1,2\},\{4\},\{3,5\}\}, then we would have f42(1)=1,f42(2)=1,f42(3)=3,f42(4)=4f_{42}(1)=1, f_{42}(2)=1, f_{42}(3)=3, f_{42}(4)=4, f42(5)=3f_{42}(5)=3. Note that 1fi(x)pi1 \leq f_{i}(x) \leq p_{i} for every admissible choice of ii and xx (the only primes that could cause problems are p1=2p_{1}=2 and p2=3p_{2}=3, but by how we chose the first two partitions in the list, the problem does not arise).

The strategy consists of revealing the five elements of the sequence whose indices a1,a2,a3,a4,a5a_{1}, a_{2}, a_{3}, a_{4}, a_{5} are defined by
an=i=152(fi(n)Ppi)n{1,2,3,4,5} a_{n}=\sum_{i=1}^{52}\left(f_{i}(n) \cdot \frac{P}{p_{i}}\right) \quad \forall n \in\{1,2,3,4,5\}

To show that this strategy works, we proceed as in part (a), studying the equalities that can hold among these five elements of the sequence.

Let pip_{i} be the period of the sequence, with 1i521 \leq i \leq 52. Since the pip_{i} terms of the sequence that repeat periodically are all distinct, as in part (a) we deduce that xan=xamx_{a_{n}}=x_{a_{m}} if and only if pip_{i} divides amana_{m}-a_{n}. Moreover, since in the sum defining ana_{n} all the terms are divisible by pip_{i} except at most the ii-th one, we deduce that pip_{i} divides amana_{m}-a_{n} if and only if pip_{i} divides fi(m)fi(n)f_{i}(m)-f_{i}(n). Finally, since fi(m)f_{i}(m) and fi(n)f_{i}(n) are both between 1 and pip_{i}, divisibility holds if and only if fi(m)=fi(n)f_{i}(m)=f_{i}(n), that is, if and only if mm and nn belong to the same subset of the ii-th partition.

It follows that, by checking for which pairs of indices mm and nn the equality xam=xanx_{a_{m}}=x_{a_{n}} holds, it is possible to uniquely reconstruct a partition of SS: the index ii of that partition in the list of the 52 partitions of SS determines the period pip_{i}.

It remains to show that there are 52 partitions of SS. To this end, let us denote more generally by BbaB_{b}^{a} the number of partitions of bb elements into aa subsets, that is, the number of ways to represent a set of bb elements as a disjoint union of aa subsets. Clearly there is only one partition of bb elements into bb or into 1 subsets, so Bbb=Bb1=1B_{b}^{b}=B_{b}^{1}=1. A partition of b+1b+1 elements into a+1a+1 subsets can be obtained in two ways: either by adding the (b+1)(b+1)-th element to one of the a+1a+1 parts of a partition of the first bb elements into a+1a+1 subsets, or by adding the (b+1)(b+1)-th element, as a subset by itself, to a partition of bb elements into aa subsets. The following relations therefore hold
Bbb=Bb1=1,Bb+1a+1=(a+1)Bba+1+Bba B_{b}^{b}=B_{b}^{1}=1, \quad B_{b+1}^{a+1}=(a+1) B_{b}^{a+1}+B_{b}^{a}
from which it is possible to iteratively complete the table below. The number of partitions of a set of 5 elements is the sum of the numbers in the last row, namely 52.

a=1a=12345
b=1b=1Bba=1B_{b}^{a}=1
211
3131
41761
511525101

Continuing the table, and summing the numbers in the kk-th row, one obtains the number of partitions of a set of kk elements.

Optimality of the strategies

The basic idea, to show that one cannot do better than the strategies illustrated above, is to argue that the only information available to the strategy must be contained in the equalities observed among the revealed numbers. An assignment of equalities among kk variables, which we imagine represent the kk numbers revealed in the kk steps of any strategy, determines a partition of the set of these kk variables. Hence, in kk steps, a strategy can distinguish at most as many periods as there are partitions of a set of kk elements, that is, the sum of the numbers in the kk-th row of the previous table.

In evaluating the solutions proposed by the contestants for this problem, the previous argument was deemed sufficient.0^{0}

However, the formal translation of this intuitive idea is not obvious, since the text of the problem explicitly allows "dynamic" strategies in which each move can depend on the outcome of the previous moves, taking into account various factors, for example the parity of the revealed numbers, whether or not they are prime, their size, and so on.

In what follows, given any subset P\mathbb{P} of the positive integers, we denote by Succ(P)\operatorname{Succ}(\mathbb{P}) the set of all sequences of positive integers that have period pPp \in \mathbb{P} and have the first pp terms distinct (pp is not necessarily a prime number). For brevity we denote elements of Succ(P)\operatorname{Succ}(\mathbb{P}) by a single letter, that is, we will briefly write xx to denote the sequence x1,x2,,xn,x_{1}, x_{2}, \ldots, x_{n}, \ldots The goal is to prove the following statement.

Lemma. Let kk be a positive integer, and let P\mathbb{P} be a subset of the positive integers. Suppose there exists a strategy that allows one to determine the period of every sequence in Succ(P)\operatorname{Succ}(\mathbb{P}) in at most kk moves.
Then the number of elements of P\mathbb{P} is less than or equal to the number of partitions of the set {1,,k}\{1, \ldots, k\}.

To prove the lemma, we need to introduce some notation. We call an m-outcome a sequence EE of mm pairs [(a1,v1),,(am,vm)]\left[\left(a_{1}, v_{1}\right), \ldots,\left(a_{m}, v_{m}\right)\right] of positive integers, where a1,,ama_{1}, \ldots, a_{m} are the indices of the terms revealed by the strategy at moves 1,,m1, \ldots, m, and v1,,vmv_{1}, \ldots, v_{m} are the corresponding revealed values.

We define the weight of EE to be the number Peso(E)={v1,,vm}\operatorname{Peso}(E)=\left|\left\{v_{1}, \ldots, v_{m}\right\}\right|, that is, the number of distinct elements among v1,,vmv_{1}, \ldots, v_{m}.

We say that a period pPp \in \mathbb{P} is credible for a given mm-outcome EE if there exists a sequence zSucc(P)z \in \operatorname{Succ}(\mathbb{P}) of period pp such that zai=viz_{a_{i}}=v_{i} for every i{1,,m}i \in\{1, \ldots, m\}.

We denote by Per(E)\operatorname{Per}(E) the subset of P\mathbb{P} consisting of the periods credible for EE, and we call the uncertainty of EE the number Inc(E)=Per(E)\operatorname{Inc}(E)=|\operatorname{Per}(E)|, that is, the number of periods among which we remain uncertain if, after mm steps, the strategy has given us EE as a result.

Suppose now that there exists a strategy that determines the period of every element of Succ(P)\operatorname{Succ}(\mathbb{P}) in at most kk moves. We may assume that the strategy always performs kk moves before stating the period (possibly by adding irrelevant moves).

We define as attainable all the mm-outcomes that can be obtained by applying the strategy to some sequence in Succ(P)\operatorname{Succ}(\mathbb{P}), and we denote by E(m)\mathcal{E}(m) the set of all attainable mm-outcomes. We will prove that the bound
Inc(E)CmPeso(E)m{1,,k},EE(m) \operatorname{Inc}(E) \leq C_{m}^{\mathrm{Peso}(E)} \quad \forall m \in\{1, \ldots, k\}, \quad \forall E \in \mathcal{E}(m)
holds, where the numbers CbaC_{b}^{a} are defined by setting Cka=1C_{k}^{a}=1 for every 1ak1 \leq a \leq k, and then working backward
Cma=aCm+1a+Cm+1a+1m{1,,k1},a{1,,m} C_{m}^{a}=a C_{m+1}^{a}+C_{m+1}^{a+1} \quad \forall m \in\{1, \ldots, k-1\}, \quad \forall a \in\{1, \ldots, m\}

Assuming this result, for m=1m=1 we will in particular have that
Inc(E)C11EE(1) \operatorname{Inc}(E) \leq C_{1}^{1} \quad \forall E \in \mathcal{E}(1)
This inequality is equivalent to the thesis, since for every 1-outcome EE the uncertainty Inc(E)\operatorname{Inc}(E), that is, the uncertainty after the first move, is exactly the number of elements of P\mathbb{P}, since clearly after the first move every period is still credible, while C11C_{1}^{1} is the number of partitions of {1,,k}\{1, \ldots, k\} (for a specific value of kk this can be verified by explicitly computing C11C_{1}^{1} by means of the recurrence; for the general case one can show, by induction on mm, that the sum
a=1mBmaCma \sum_{a=1}^{m} B_{m}^{a} C_{m}^{a}
is independent of 1mk1 \leq m \leq k, from which the conclusion follows by comparing the cases m=1m=1 and m=km=k).

To prove inequality (1), we proceed by backward induction on mm. If EE(k)E \in \mathcal{E}(k), then Inc(E)=1\operatorname{Inc}(E)=1, whatever the weight of EE is, since by hypothesis the strategy works, so every possible outcome after kk moves uniquely identifies the period.

Suppose now that (1) holds for some m+1m+1, with 1mk11 \leq m \leq k-1, and let us show that it holds for mm. Consider then an attainable mm-outcome EE, which we think of as always being of the form [(a1,v1),,(am,vm)]\left[\left(a_{1}, v_{1}\right), \ldots,\left(a_{m}, v_{m}\right)\right]. Observe that the set Per(E)\operatorname{Per}(E) of periods credible for EE is contained in the union of the sets Per(E)\operatorname{Per}\left(E'\right), where EE' ranges over all the attainable (m+1)(m+1)-outcomes that agree with EE up to step mm. Note also that the index am+1a_{m+1} of every EE' of this type is always the same, since it depends only on the history up to step mm. Consequently, all the (m+1)(m+1)-outcomes we are interested in are obtained by adding to EE a pair of the form (am+1,v)\left(a_{m+1}, v\right), where vv ranges over a suitable set F\mathcal{F} of positive integers.

We have thus obtained the inclusion
Per(E)vFPer([(a1,v1),,(am,vm),(am+1,v)]) \operatorname{Per}(E) \subseteq \bigcup_{v \in \mathcal{F}} \operatorname{Per}\left([ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}), (a_{m+1}, v) ]\right)

Now the value vv may or may not coincide with one of the values v1,,vmv_{1}, \ldots, v_{m} involved in EE. This leads us to think of the union in (2) as the union of the set
v{v1,,vm}Per([(a1,v1),,(am,vm),(am+1,v)]) \bigcup_{v \in\{v_{1}, \ldots, v_{m}\}} \operatorname{Per}\left([ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}), (a_{m+1}, v) ]\right)
and the set
wF\{v1,,vm}Per([(a1,v1),,(am,vm),(am+1,w)]) \bigcup_{w \in \mathcal{F} \backslash\{v_{1}, \ldots, v_{m}\}} \operatorname{Per}\left([ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}), (a_{m+1}, w) ]\right)

In (3) the number of sets we are taking the union of is Peso(EE), and each of them has, by the induction hypothesis, a number of elements less than or equal to Cm+1Peso(E)C_{m+1}^{\operatorname{Peso}(E)}. It follows that the number of elements of the first union is less than or equal to
Peso(E)Cm+1Peso(E) \operatorname{Peso}(E) \cdot C_{m+1}^{\operatorname{Peso}(E)}

In (4), the sets we are taking the union of are (fortunately) all equal, since the set of periods compatible with a given (m+1)(m+1)-outcome [(a1,v1),,(am,vm),(am+1,w1)][ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}), (a_{m+1}, w_{1}) ] coincides with the set of periods compatible with the (m+1)(m+1)-outcome [(a1,v1),,(am,vm),(am+1,w2)][ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}), (a_{m+1}, w_{2}) ], whatever positive integers w1w_{1} and w2w_{2} are, provided they are different from v1,,vnv_{1}, \ldots, v_{n}. Indeed, if pp is a period credible given the first (m+1)(m+1)-outcome, then there exists a sequence zSucc(P)z \in \operatorname{Succ}(\mathbb{P}) of period pp such that zaj=vjz_{a_{j}}=v_{j} for jj ranging from 1 to mm, and zam+1=w1z_{a_{m+1}}=w_{1}; now, replacing in the sequence zz every occurrence of w1w_{1} with w2w_{2}, and vice versa, one obtains a new sequence in Succ(P)\operatorname{Succ}(\mathbb{P}) of period pp and compatible with the second (m+1)(m+1)-outcome, and hence pp is credible also given the second outcome. The converse is analogous.

Finally, observe that all the (equal) sets appearing in the union (4) are the credible periods for suitable admissible (m+1)(m+1)-outcomes whose weight equals Peso(E)+1\operatorname{Peso}(E)+1, and hence by the induction hypothesis the number of elements of the second union is less than or equal to Cm+1Peso(E)+1C_{m+1}^{\operatorname{Peso}(E)+1}.

Returning to (2), we have shown that for every EE(m)E \in \mathcal{E}(m) the bound
Inc(E)Peso(E)Cm+1Peso(E)+Cm+1Peso(E)+1=CmPeso(E) \operatorname{Inc}(E) \leq \operatorname{Peso}(E) \cdot C_{m+1}^{\operatorname{Peso}(E)}+C_{m+1}^{\operatorname{Peso}(E)+1}=C_{m}^{\operatorname{Peso}(E)}
holds, which completes the induction step, and hence the proof of the lemma.

An alternative approach to the lemma consists of arguing by contradiction, by showing that, if the number of elements of P\mathbb{P} is greater than the number of partitions of {1,,k}\{1, \ldots, k\}, then for every strategy SS in kk steps there exist two sequences in Succ(P)\operatorname{Succ}(\mathbb{P}), of different period, on which the strategy produces the same kk-outcome, thus making it impossible to uniquely determine the period.

To show this result, we say that an m-outcome [(a1,v1),,(am,vm)][ (a_{1}, v_{1}), \ldots, (a_{m}, v_{m}) ] is moderate if v1=1v_{1}=1 and vimax{v1,,vi1}+1v_{i} \leq \max \{v_{1}, \ldots, v_{i-1}\}+1 for every i{2,,m1}i \in\{2, \ldots, m-1\}. We say that a sequence is SS-moderate if the strategy SS, applied to the sequence, produces a moderate kk-outcome (and hence all the mm-outcomes obtained along the way are also moderate). In other words, the value revealed (not the index) by the strategy SS on an SS-moderate sequence at step mm is one of the previous values, or the maximum of the previous values increased by 1.

The existence of the two sequences of different period that produce the same kk-outcome now follows, by the pigeonhole principle, from three claims.

1. If two kk-outcomes of the same strategy SS have the same values in the same order, then they also have the same indices in the same order.
2. The number of possible kk-outcomes of a given strategy SS applied to SS-moderate sequences is less than or equal to the number of partitions of {1,,k}\{1, \ldots, k\}.
3. For every strategy SS and for every period pPp \in \mathbb{P}, there exists in Succ(P)\operatorname{Succ}(\mathbb{P}) at least one SS-moderate sequence of period pp.

The first claim is proved by induction, using the fact that the index that will be revealed at step m+1m+1 depends only on the indices and values revealed up to step mm.

To prove the second claim, observe that, thanks to the first claim, a moderate kk-outcome obtained from a given strategy SS is uniquely determined by the kk-tuple (v1,,vk)(v_{1}, \ldots, v_{k}) of its values. At this point it suffices to observe that there is a bijective correspondence between such kk-tuples and the partitions of {1,,k}\{1, \ldots, k\} (it suffices to consider the steps at which one obtained as value 1,2,1,2, \ldots).

To prove the third claim, consider the largest integer m{1,,k}m \in\{1, \ldots, k\} for which there exists a sequence in Succ(P)\operatorname{Succ}(\mathbb{P}) of period pp whose outcomes are SS-moderate up to step mm. Observe first that, denoting by a1a_{1} the index of the term revealed by the strategy SS at the first step, there certainly exists a sequence of period pp with xa1=1x_{a_{1}}=1, so mm is well defined, in the sense that the set of which it is the maximum is not empty.

Now if m=km=k there is nothing to prove. If instead m<km<k, consider any sequence xSucc(P)x \in \operatorname{Succ}(\mathbb{P}) of period pp that achieves the maximum. At step m+1m+1 the strategy SS applied to xx will produce a pair (am+1,w)(a_{m+1}, w) for some w>w+1w>w'+1, where ww' is the maximum of the values revealed in the first mm steps. But if we now consider the sequence yy obtained by swapping in xx every occurrence of ww with w+1w'+1, and vice versa, one can check that yy is still an element of Succ(P)\operatorname{Succ}(\mathbb{P}) of period pp, and its outcomes are moderate at least up to step m+1m+1 (and coincide with those of xx up to step mm). This contradicts the maximality of mm.

Concluding remarks

The "elephant in the room" in problems of this type is the concept of strategy. The fundamental question one might ask is: what is a strategy? The problem can change a great deal depending on the answer to this question.

In this specific case, the problem could have been formulated using only "static" strategies, in which the "player" must declare at the very beginning all the indices of the terms he wants to reveal. In this formulation a strategy in nn steps is thus, from a formal point of view, simply an n-tuple of positive integers, that is, precisely the requested indices. The solutions presented at the beginning for parts (a) and (b) indeed show static strategies that solve the problem in a certain number of moves. As for optimality, the proof becomes much simpler if one restricts to static strategies only, because then a value-swapping argument suffices to rigorously show that the only relevant information consists of the equalities among the revealed values.

A broader class of strategies includes those we might call "deterministic dynamic" strategies. The player now chooses the first index a1a_{1} to reveal, and then at each subsequent move chooses the index am+1a_{m+1} based on the m-outcome. The strategy is thus formally made up of a number (the first index) and a function that associates to every mm-outcome the next index. Determinism consists in the fact that the initial step is always the same, and the same mm-outcome will always lead to requesting the same index at the next step. The two proofs of the optimality lemma given above, as written, are conceived within the class of deterministic dynamic strategies.

An even broader class of strategies includes those we might call "probabilistic dynamic" strategies. After seeing the m-outcome, the player now "rolls a die", and chooses the next index to reveal based on the m-outcome and the outcome of the die (and similarly for the choice of the first index). The same mm-outcome can thus now lead to investigating different indices at the next step. The two previous proofs of optimality can, with small modifications, be adapted to also include strategies of this type, provided one assumes that the die behaves "fairly". On the other hand, we cannot allow as a "strategy" the use of an unfair die which, for example, on the first move makes us reveal the 2021st term, and on the second move "by chance" happens to request precisely the term of index 2021+p2021+p, where pp is the period of the sequence. With such a die, if pp is prime, we would always manage in two moves!

0^{0} These are known in the literature as Bell numbers.
1^{1} Result of uncertain attribution, often cited in olympiad literature as Passaro's Lemma. Note that it can be seen as dual to the better-established Damiano's Lemma, or as a corollary of the lesser-known Pierrat's Lemma.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement translated into English from it; metadata (topic, difficulty) added by this project.