Fixed point in occurrence counting(C言語)
In this program, any sequence S of integers in input produces as output the fixed-point sequence P and the smallest possible number of occurrence-counting applications that leads to P. The occurrence-counting operation transforms a sequence S ={s1, s2, …, sn} of length n into a sequence C= {c1, c2, …, cn} of the same length. Here ci is the occurrence count of si for i=1,..,n. For example, for S ={3,4,1,5,9,2,6,5,3} we have C ={2,1,1,2,1,1,1,2,2}.You can apply the occurrence-counting operation again on the sequence C to obtain P ={4,5,5,4,5,5,5,4,4}. This sequence does not change even if you apply the occurrence counting again. We call P the fixed point of sequence S. For any sequence S there exists a fixed-point sequence P, if we repeatedly apply the occurrence-counting operation sufficient times enough. See the figure for another example.