[Huawei OD machine test 2023 B volume | 100 points] Sequence description (C++ Java JavaScript Python)

topic description

There is a sequence a[N] (N=60), starting from a[0], each item is a number. A[n+1] in the sequence is a description of a[n]. where a[0]=1.

The rules are as follows:

a[0]:1

a[1]:11 (meaning: the previous item a[0]=1 is a 1, that is, "11". It means that a[0] appears one time "1" in a row from left to right)

a[2]:21 (meaning: the previous item a[1]=11, from left to right: it is composed of two 1s, namely "21". It means that a[1] appears continuously from left to right twice "1")

a[3]:1211 (meaning: its previous item a[2]=21, from left to right: it is composed of a 2 and a 1, that is, "1211". It means that a[2] is continuous from left to right 1 occurrence of "2", then 1 consecutive occurrence of "1")

a[4]:111221 (meaning: the previous item a[3]=1211, from left to right: it is composed of one 1, one 2, and two 1s

Supongo que te gusta

Origin blog.csdn.net/shangyanaf/article/details/130926491
Recomendado
Clasificación