f [ i ] f[i] f [ i ] means there isiiThe number of plans for i cows and the last cow must be a bull.
f [ i ] = ∑ 0 i − k − 1 f [ i ] f[i] =\sum_{0}^{i-k-1} f[i] f[i]=∑0i−k−1f[i] ( s [ i − k , i − 1 ] ) (s[i-k,i-1]) (s[i−k,i−1 ] ) Only cows are allowed.
The final answer: ∑ 0 nf [i] \sum_{0}^{n}f[i]∑0nf [ i ] , do things in categories, the principle of addition.
Use f [i] f[i] directlyf [ i ] means there isiiNumber of plans for i cattle
If iii cow is a cow, theni − 1 i-1i−1 head can be placed casually according to the requirements of the subject.
If iii cow is a bull,s [i − k] s[ik]s[i−k]~ s [ i − 1 ] s[i-1] s[i−1 ] None can be bulls, only cows. So at this timei − k − 1 ik-1i−k−1 cow is placed randomly according to the requirements of the subject. f [i] = f [i − 1] + f [i − k − 1] f[i]=f[i-1]+f[ik-1]f[i]=f[i−1]+f[i−k−1]