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

24930번 - Ordinary Ordinals 다국어

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

문제

Sets, sets, sets. Everything in math is just a set. Even the natural numbers can be represented as sets. For example, we can represent the the number 0ドル$ as the empty set $\{\}$. The number 1ドル$ can be represented as $\{\{\}\}$.

But what about 2ドル$? Consider $\{\{\},\{\{\}\}\},ドル the set containing both the empty set and $\{\{\}\}$. This is a nice choice for 2ドル$ for two reasons: we have that 0ドル$ and 1ドル$ are elements of 2ドル$ and we also have that 0ドル$ and 1ドル$ are subsets of 2ドル$.

In general, for $N>0$ we can represent $N$ as the set $\{0,1, \dots ,N-1\}$ where we recursively apply the representations for 0,1,ドル \dots ,N-1$. For example: $$\begin{eqnarray*} 3 & = & \{ 0, 1, 2\} \\ & = & \{ \{ \} , \{ 0\} , \{ 0, 1\} \} \\ & = & \{ \{ \} , \{ \{ \} \} , \{ \{ \}, \{ 0\} \} \} \\ & = & \{ \{ \} , \{ \{ \} \} , \{ \{ \} , \{ \{ \} \} \} \} \end{eqnarray*}$$

Thus, for each 0ドル≤i<N,ドル $i$ is both a member of $N$ and a subset of $N$. Another nice feature is the size of the set representing $N$ is also $N$. But what is not so nice is the number of characters it takes to write such a set. Given a natural number $N≥0,ドル how many braces and commas are required to write out the set representing $N$ in the above manner?

More specifically, let $f(N)$ be the number of bracket and comma characters required to write out the set representing $N$. Since $f(N)$ can be quite large, your job is to determine $f(N)$ modulo some positive integer $M$.

입력

Input consists of two integers $N$ (0ドル≤N<2^{63}$) and $M$ (1ドル≤M<2^{31}$) as described above.

출력

Display the value of $f(N)$ reduced modulo $M$. That is, the remainder that would be left if you divided $f(N)$ by $M$.

제한

예제 입력 1

2 100

예제 출력 1

9

예제 입력 2

3 100

예제 출력 2

19

예제 입력 3

3 7

예제 출력 3

5

예제 입력 4

1000000000 1000000007

예제 출력 4

851562505

힌트

출처

University > University of Alberta Programming Contest > UAPC 2022 > Division 1 F번

University > University of Alberta Programming Contest > UAPC 2022 > Division 2 F번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

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

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