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

16620번 - Interesting World of Arrays 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB48201539.474%

문제

Gwen is just about to finish her Ph.D. entitled The Interesting World of Arrays. She studies many different kinds of arrays, but her favourite type is counting arrays. A counting array simply counts the number of times each possible value appears in an array. Formally, [c0, c1, c2, . . . , cn−1] is the counting array of A = [a0, a1, . . . , an−1] if there are c0 zeroes in A, c1 ones in A, c2 twos in A, and so on. For example, if A = [4, 1, 2, 0, 2], then its counting is [1, 1, 2, 0, 1]. Counting arrays are not defined unless ai is an integer and 0 ≤ ai < n for all 0 ≤ i < n.

The last chapter of Gwen’s thesis is on mod-m self-describing arrays. Let A = [a0, a1, . . . , an−1] be an array with counting array [c0, c1, . . . , cn−1]. For a positive integer m, the array A is a mod-m self-describing array if ai ≡ ci (mod m) for all 0 ≤ i < n. That is, ai and ci leave the same remainder when divided by m. For example, consider A = [6, 6, 4, 6, 3, 5, 3] and its counting array [0, 0, 0, 2, 1, 1, 3]. Since they are the same modulo 2 (both become [0, 0, 0, 0, 1, 1, 1]), the array A is said to be a mod-2 self-describing array.

The only thing left to do before Gwen submits her thesis is to compute the number of mod-m self-describing arrays for various values of n and m. Please help compute these numbers.

입력

The input consists of a single line containing two integers n (1 ≤ n ≤ 12), which is the length of the array, and m (2 ≤ m ≤ 109), which is the modulus.

출력

Display the number of mod-m self-describing arrays of length n.

제한

예제 입력 1

4 3

예제 출력 1

6

예제 입력 2

5 3

예제 출력 2

20

예제 입력 3

7 4

예제 출력 3

72

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2018 ACM South Pacific Programming Contest I번

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

출처

대학교 대회

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

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