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

26246번 - Expected length of the minimum cycle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB32266.667%

문제

You are given a positive integer $N,ドル find the expected length of the minimum cycle in permutation of integers from 1ドル$ to $N$. All permutations are equiprobable.

Consider the answer is an irreducible fraction $\frac{A}{B}$. Output $A \cdot B^{-1} \mod P,ドル where $P$ is a given prime number. It is guaranteed that $gcd(B, P) = 1$.

입력

The only line of input contains two integers $N$ and $P$ (1ドル \le N \le 10^4,ドル 10ドル^4 < P \le 10^9 + 33$). It's guaranteed that $P$ is a prime number.

출력

Output the answer to the problem in a single line.

제한

예제 입력 1

2 1000000007

예제 출력 1

500000005

예제 입력 2

3 1000000007

예제 출력 2

666666673

힌트

출처

Contest > Open Cup > 2016/2017 Season > Stage 7: Grand Prix of Dolgoprudny B번

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

출처

대학교 대회

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

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