Divisible by 3 - MarisaOJ: Marisa Online Judge

Divisible by 3

Time limit: 1000 ms
Memory limit: 256 MB
You are given array $A$ of $n$ integers. There are $q$ queries of the either form: - `1 l r`: increasing $A_l,A_{l+1},...,A_r$ by $1$. - `2 l r`: find the number of number divisible by $3$ in subarray $A_l,A_{l+1},...,A_r$. ### Input - The first line contains 2 integers $n, q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines, each line contains 3 integers, a query. ### Output - Print the answer for each query of type $2$. ### Constraints - $1 \le n, q\le 10^5$. - $1 \le l, r \le n$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 5 3 1 2 2 3 2 2 2 4 1 1 5 2 3 5 ``` Output: ``` 1 2 ```