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

21165번 - Redundant Binary Notation 다국어

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

문제

Binomial trees of a binomial heap. Wikimedia, cc-by-sa

Redundant binary notation is similar to binary notation, except instead of allowing only 0ドル$’s and 1ドル$’s for each digit, we allow any integer digit in the range $[0, t],ドル where $t$ is some specified upper bound. For example, if $t = 2,ドル the digit 2ドル$ is permitted, and we may write the decimal number 4ドル$ as 100ドル,ドル 20ドル,ドル or 12ドル$. If $t=1,ドル every number has precisely one representation, which is its typical binary representation. In general, if a number is written as $d_l d_{l-1} \ldots d_1 d_0$ in redundant binary notation, the equivalent decimal number is $d_l\cdot2^l + d_{l-1}\cdot2^{l-1} + \cdots + d_1\cdot2^1 + d_0\cdot2^0$.

Redundant binary notation can allow carryless arithmetic, and thus has applications in hardware design and even in the design of worst-case data structures. For example, consider insertion into a standard binomial heap. This operation takes $O(\log n)$ worst-case time but $O(1)$ amortized time. This is because the binary number representing the total number of elements in the heap can be incremented in $O(\log n)$ worst-case time and $O(1)$ amortized time. By using a redundant binary representation of the individual binomial trees in a binomial heap, it is possible to improve the worst-case insertion time of binomial heaps to $O(1)$.

However, none of that information is relevant to this question. In this question, your task is simple. Given a decimal number $N$ and the digit upper bound $t,ドル you are to count the number of possible representations $N$ has in redundant binary notation with each digit in range $[0, t]$ with no leading zeros.

입력

Input consists of a single line with two decimal integers $N$ (0ドル \leq N \leq 10^{16}$) and $t$ (1ドル \leq t \leq 100$).

출력

Output in decimal the number of representations the decimal number $N$ has in redundant binary notation with each digit in range $[0, t]$ with no leading zeros. Since the number of representations may be very large, output the answer modulo the large prime 998ドル,244円,353円$.

제한

예제 입력 1

4 2

예제 출력 1

3

예제 입력 2

6 3

예제 출력 2

4

예제 입력 3

479 1

예제 출력 3

1

예제 입력 4

3846927384799 62

예제 출력 4

690163857

예제 입력 5

549755813887 2

예제 출력 5

1

힌트

출처

ICPC > Regionals > North America > North Central North America Regional > NCNA 2020 C번

ICPC > Regionals > North America > Southern California Regional > 2020 Southern California Regional 9번

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

출처

대학교 대회

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

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