#P10587. 「ALFR Round 2」C 小 Y 的数

「ALFR Round 2」C 小 Y 的数

Problem Description

Xiao Y likes the number 4242 very much, so he also likes numbers that start with 4242 and then keep appending 4,24,2 alternately, such as 42,424,4242,42,424,4242,\cdots. Xiao Y gives you an integer sequence aa of length nn. There are mm operations, and there are four types of operations:

  • 1 l r x Add xx to the numbers in positions lrl\sim r.

  • 2 l r x Multiply the numbers in positions lrl\sim r by xx.

  • 3 l r x Set the numbers in positions lrl\sim r to xx.

  • 4 l r Query how many numbers in positions lrl\sim r are liked by Xiao Y.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers a1,a2,a3ana_1,a_2,a_3\cdots a_n.

The next mm lines each contain 33 or 44 integers describing one operation.

Output Format

Output one line for each operation of type 44, containing its answer.

8 8
41 42 43 44 45 46 47 47
4 1 8
1 1 8 377
4 1 8
2 1 1 100
1 1 8 624
4 1 7
3 1 8 424242
4 1 5
1
2
1
5

Hint

Sample Explanation

In the 11st operation, query how many numbers in the interval 181\sim8 are liked by Xiao Y. There is 11 such number, which is a2a_2.

In the 22nd operation, add 377377 to the numbers in the interval 181\sim8, and the sequence aa becomes 418,419,420,421,422,423,424,424418,419,420,421,422,423,424,424.

In the 33rd operation, query how many numbers in the interval 181\sim8 are liked by Xiao Y. There are 22 such numbers, which are a7,a8a_7,a_8.

In the 44th operation, multiply the numbers in the interval 111\sim1 by 100100, and the sequence aa becomes 41800,419,420,421,422,423,424,42441800,419,420,421,422,423,424,424.

In the 55th operation, add 624624 to the numbers in the interval 181\sim8, and the sequence aa becomes 42424,1043,1044,1045,1046,1047,1048,104842424,1043,1044,1045,1046,1047,1048,1048.

In the 66th operation, query how many numbers in the interval 171\sim7 are liked by Xiao Y. There is 11 such number, which is a1a_1.

In the 77th operation, set the numbers in the interval 181\sim8 to 424242424242, and the sequence aa becomes $424242,424242,424242,424242,424242,424242,424242,424242$.

In the 88th operation, query how many numbers in the interval 151\sim5 are liked by Xiao Y. There are 55 such numbers, which are a1,a2,a3,a4,a5a_1,a_2,a_3,a_4,a_5.

Constraints

Subtask Points Constraints
00 2020 n,m104n,m\le10^4
11 8080 -

For 100%100\% of the testdata, 1n,m,ai,x5×1051\le n,m,a_i,x\le5\times10^5, 1l,rn1\le l,r\le n.

It is guaranteed that after each operation, 1ai5×1051\le a_i\le5\times10^5.

Translated by ChatGPT 5