#P11856. [CSP-J 2022 山东] 吟诗
[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 characters, each character can be represented by an integer between and . There are also three positive integers . If the poem contains three consecutive segments such that the sum of the first segment is , the sum of the second segment is , and the sum of the third segment is , then Xiaoxiami thinks this poem has a wonderful touch.
That is, for a sequence of length , $a_{1},a_{2},\dots a_{n} \left(1\le a_{i}\le10\right)$, if there exist such that and and 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 , , , , then among all sequences of length , it is obvious that there are sequences in total. One of them, , has a wonderful touch, because there exist three consecutive intervals , , whose sums are , , , respectively.
Xiaoxiami wants to know, given (there are sequences in total, i.e. 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 .
Input Format
One line with 4 positive integers separated by spaces, representing the sequence length and the values of in the problem.
Output Format
One line with one integer, representing the answer modulo .
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 can be constructed to satisfy the requirement, so the answer is .
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5