#P3176. [HAOI2015] 数字串拆分

[HAOI2015] 数字串拆分

Description

You have a digit string s0s_0 of length nn.

Define f(s)f(s) as the number of ways to split ss into a sum of numbers in the range 1m1 \sim m. For example, when m=2m=2, f(4)=5f(4)=5, namely 4=1+1+1+1=1+1+2=1+2+1=2+1+1=2+24=1+1+1+1=1+1+2=1+2+1=2+1+1=2+2.

Define g(s)g(s) as follows: split the digit string ss into several numbers (leading 00 are allowed), let their sum be xx, then g(s)g(s) is the sum of f(x)f(x) over all such cases. For example, g(123)=f(1+2+3)+f(1+23)+f(12+3)+f(123)g(123)=f(1+2+3)+f(1+23)+f(12+3)+f(123).

Given s0s_0 and mm, compute g(s0)g(s_0).

Take the answer modulo 998,244,353998,244,353.

Input Format

The first line contains a string, which represents s0s_0.

The second line contains an integer, which represents mm.

Output Format

Output a single integer representing the answer.

123
3
394608467

Hint

Constraints and Conventions

  • For 100%100\% of the testdata, it is guaranteed that 1s05001 \le |s_0| \le 500, 1m51 \le m \le 5, and s0s_0 contains only digit characters.

Translated by ChatGPT 5