#P8043. [COCI 2016/2017 #7] KLAVIR
[COCI 2016/2017 #7] KLAVIR
Problem Description
Young Alisa likes to play the piano using only one finger. However, since Alisa has never learned how to play the piano, her playing process is completely random. More precisely, she chooses any one of the notes on the piano with equal probability, and this choice is independent of all previously chosen notes.
Alisa's good friend Mirta wants to hear a piece consisting of consecutive notes . But since Alisa's playing is completely random, Mirta only wants to know, for every , the expected number of choices Alisa makes until Mirta hears the consecutive notes for the first time. To avoid precision loss, take the answers modulo .
Input Format
The first line contains an integer , the number of notes.
The second line contains an integer , the number of notes in the piece that Mirta wants to hear.
The third line contains integers , where is the -th note of the piece.
Output Format
Output lines, each containing a positive integer. The -th line should be the expected number of choices Alisa makes until Mirta hears the consecutive notes for the first time, taken modulo .
2
2
1 2
2
4
2
2
1 1
2
6
3
3
1 2 3
3
9
27
Hint
Constraints
For of the testdata, .
For all testdata, , , .
Source
This problem is from COCI 2016-2017 CONTEST 7 T6 KLAVIR, with the original testdata settings and a full score of points.
Translated and organized by Eason_AC.
Translated by ChatGPT 5