#P11856. [CSP-J 2022 山东] 吟诗

    ID: 10227 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2022山东枚举状态合并进制CSP-J 入门级

[CSP-J 2022 山东] 吟诗

Background

Due to the impact of the pandemic, Shandong Province canceled the CSP-J 2022 certification event, and set a new problem in March of the next year to hold a make-up contest within the province.

Problem Description

"Articles are naturally formed; a wonderful touch is gained by chance."

Reciting poetry is a common way to express feelings. After the war ended, years of military life made Xiaoxiami like the bold style of poetry.

One day, Xiaoxiami suddenly wanted to recite poetry. The famous bold-style poet Su Shi had the boldness of “老夫聊发少年狂,左牵黄,右擎苍。”, and also the sorrow of “十年生死两茫茫,不思量,自难忘。”. Xiaoxiami longed for this, so he also wanted to write a poem using the tune pattern name "Jiangchengzi".

Xiaoxiami wants to write a poem that can be passed down through the ages. Based on experience, if a poem contains a "wonderful touch" (miaoshou), it can be passed down through the ages.

More specifically, for a poem of NN characters, each character can be represented by an integer between 11 and 1010. There are also three positive integers X,Y,Z(1X7,1Y5,1Z5)X,Y,Z\left(1\le X\le7,1\le Y\le5,1\le Z\le5\right). If the poem contains three consecutive segments such that the sum of the first segment is XX, the sum of the second segment is YY, and the sum of the third segment is ZZ, then Xiaoxiami thinks this poem has a wonderful touch.

That is, for a sequence of length nn, $a_{1},a_{2},\dots a_{n} \left(1\le a_{i}\le10\right)$, if there exist i,j,k,l(1i<j<kln)i,j,k,l\left(1\le i<j<k\le l\le n\right) such that ai+ai+1+aj1=Xa_{i}+a_{i+1}+\dots a_{j-1}=X and aj+aj+1+ak1=Ya_{j}+a_{j+1}+\dots a_{k-1}=Y and ak+ak+1+al=Za_{k}+a_{k+1}+\dots a_{l}=Z all hold at the same time, then the sequence is considered to have a wonderful touch (note: the second segment is immediately after the first segment, and the third segment is immediately after the second segment).

For example, if N=7N=7, X=7X=7, Y=3Y=3, Z=3Z=3, then among all sequences of length 77, it is obvious that there are 10710^{7} sequences in total. One of them, [1,5,2,2,1,3,4]\left[1,5,2,2,1,3,4\right], has a wonderful touch, because there exist three consecutive intervals [2,3]\left[2,3\right], [4,5]\left[4,5\right], [6,6]\left[6,6\right] whose sums are X=7X=7, Y=3Y=3, Z=3Z=3, respectively.

Xiaoxiami wants to know, given N,X,Y,ZN,X,Y,Z (there are 10n10^{n} sequences in total, i.e. 10n10^{n} poems), how many poems contain a wonderful touch. Please help him compute the answer.

Since the answer may be very large, please output it modulo 998244353998244353.

Input Format

One line with 4 positive integers N,X,Y,ZN,X,Y,Z separated by spaces, representing the sequence length and the values of X,Y,ZX,Y,Z in the problem.

Output Format

One line with one integer, representing the answer modulo 998244353998244353.

3 2 3 3
1
4 7 5 5
34
23 7 3 5
824896638

Hint

Explanation for Sample 1

Among all possible sequences, only one sequence [2,3,3]\left[2,3,3\right] can be constructed to satisfy the requirement, so the answer is 11.

Constraints

For 30%30\% of the testdata, 3N53\le N\le5.

For 60%60\% of the testdata, 3N203\le N\le20.

For 100%100\% of the testdata, 3N40,1X7,1Y5,1Z53\le N\le40,1\le X\le7,1\le Y\le5,1\le Z\le5.

Translated by ChatGPT 5