Logo
(追記) (追記ここまで)

14416번 - Klavir 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB47191451.852%

문제

Young Alisa likes to play the piano using only one finger. Unfortunately, Alisa never learned to play the piano, so her playing is entirely random. More precisely, any time she chooses a tone to play, she does it independently of all previous tones, and chooses each of the N tones with the same probability.

Her good friend Mirta wants to listen to a composition containing M consecutive tones, but since Alisa plays the piano randomly, Mirta does not know how long she will have to wait to hear an array of exactly these M tones. Help Mirta determine the expected number of key presses in order to hear, for the first time, her wanted array of consecutive tones. Moreover, since Mirta is a very curious girl, she also wants to know the expected number of key presses for each prefix of her wanted array of tones.

입력

The first line of input contains the positive integer N, the number of different piano tones (1 ≤ N ≤ 100).
The second line of input contains the positive integer M, the length of the wanted array (1 ≤ M ≤ 106 ).
The third line of input contains the array of M positive integers between 1 and N.

<Scoring>

In test cases worth 64 points in total, it will hold 1 ≤ M ≤ 200.

출력

The i th of the following M lines must contain the expected number of key presses in order for Mirta to hear the prefix of length i of her wanted array of tones, modulo​ 109 + 7.
The test data will be such that the expected number of key presses will always be an integer.

제한

예제 입력 1

2
2
1 2

예제 출력 1

2
4

예제 입력 2

2
2
1 1

예제 출력 2

2
6

예제 입력 3

3
3
1 2 3

예제 출력 3

3
9
27

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2016/2017 > Contest #7 6번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /