AtCoder Beginner Contest 322
G
Two Kinds of Base
AtCoder
⌀ 2876
原题
翻译中…

Problem Statement

翻译中…

For a non-negative integer sequence $S=(S_1,S_2,\dots,S_k)$ and an integer $a$, we define the function $f(S,a)$ as follows:

翻译中…
  • $f(S,a) = \sum_{i=1}^{k} S_i \times a^{k - i}$.
翻译中…

For example, $f((1,2,3),4) = 1 \times 4^2 + 2 \times 4^1 + 3 \times 4^0 = 27$, and $f((1,1,1,1),10) = 1 \times 10^3 + 1 \times 10^2 + 1 \times 10^1 + 1 \times 10^0 = 1111$.

翻译中…

You are given positive integers $N$ and $X$. Find the number, modulo $998244353$, of triples $(S,a,b)$ of a sequence of non-negative integers $S=(S_1,S_2,\dots,S_k)$ and positive integers $a$ and $b$ that satisfy all of the following conditions.

翻译中…
  • $k \ge 1$
  • $a,b \le N$
  • $S_1 \neq 0$
  • $S_i < \min(10,a,b)(1 \le i \le k)$
  • $f(S,a) - f(S,b) = X$
翻译中…

Constraints

翻译中…
  • $1 \le N \le 10^9$
  • $1 \le X \le 2 \times 10^5$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N X

翻译中…

Output

翻译中…

Print the number, modulo $998244353$, of triples $(S,a,b)$ of a sequence of non-negative integers $S=(S_1,S_2,\dots,S_k)$ and positive integers $a$ and $b$ that satisfy the conditions.

翻译中…

样例

Input #1
4 2
Output #1
5
The five triples $(S,a,b)=((1,0),4,2),((1,1),4,2),((2,0),4,3),((2,1),4,3),((2,2),4,3)$ satisfy the conditions.
Input #2
9 30
Output #2
31
Input #3
322322322 200000
Output #3
140058961
题目信息
题号
abc322_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。