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

23512번 - Interesting Permutations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 512 MB18000.000%

문제

Vasya studies permutations of length $n$: sequences of $n$ integers such that every integer from 1ドル$ to $n$ occurs in the sequence exactly once. Vasya says a permutation is $k$-interesting if its first $k$ elements are pairwise coprime. By this definition, if a permutation is $i$-interesting, it is also $(i - 1)$-interesting.

Now Vasya wants to find the number of $i$-interesting permutations for all $i$ from 1ドル$ to $n$. If there is no $i$-interesting permutation for a given $i,ドル Vasya won't bother calculating for larger values of $i$. For example, as numbers 2ドル$ and 4ドル$ are not coprime, there is no 5ドル$-interesting permutation of length 5ドル$.

Vasya does not like huge integers, so he calculates the number of permutations modulo a given integer $m$. Help him do it.

입력

The first line contains two integers $n$ and $m$ (1ドル \le n \le 100,ドル 1ドル \le m \le 10^9$).

출력

Print $k$ lines, where $k$ is the maximum number such that there is at least one $k$-interesting permutation of length $n$. On the $i$-th line, print the remainder modulo $m$ of the number of $i$-interesting permutations of length $n$.

제한

예제 입력 1

5 239

예제 출력 1

120
108
84
48

예제 입력 2

4 8

예제 출력 2

0
4
4

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 17: Grand Prix of Baltic Sea B번

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

출처

대학교 대회

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

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