#P3689. [ZJOI2017] 多项式
[ZJOI2017] 多项式
Description
Kotori Itsuka recently studied the properties of polynomials with coefficients modulo 2. She found that one can obtain a very long string using multiplication of polynomials modulo 2:
For an -degree polynomial with coefficients 0 or 1, we compute modulo 2. Then is an -degree polynomial with coefficients. Writing these coefficients from the highest degree to the lowest degree gives a 01 string of length .
For example, for the polynomial , we compute $g\left( x \right) = f\left( x \right)^{3} = x^{9} + x^{7} + x^{6} + x^{5} + x^{2} + x^{1} + 1$, thus we obtain a string of length 10: 1011100111.
Now given a polynomial of degree , integers , , , and a 01 string of length . Let be the string obtained from , and let denote the substring from the -th character to the -th character of . Kotori wants to know how many times appears in .
Input Format
The first line contains an integer denoting the number of test cases.
For each test case, the first line contains five integers .
The second line contains a 01 string of length representing the coefficients of the polynomial . The -th character represents the coefficient of degree of .
The third line contains a string of length representing the string .
Output Format
For each test case, output a single integer denoting the answer.
1
3 3 2 1 10
1011
01
2
Hint
Time and Space Limit
Time limit: 3 s, Memory limit: 512 MB.
Constraints

Translated by ChatGPT 5
京公网安备 11011102002149号