| IME++ Open Contest 2024 |
|---|
| Закончено |
Davi Holanda, usually known by his nickname, Deaga, has been fiddling around with arithmetic progressions, as it's something very important to know for the entrance exam of the Institute of Meaningful Equations, otherwise known as IME. He discovered the existence of third-order arithmetic progressions, which are arithmetic progressions that, given the first four elements, follow the construction rule: $$$a_{i + 3} - 3a_{i + 2} + 3a_{i + 1} - a_i = k$$$, where $$$k$$$ is some non-zero constant. The constant varies depending on the sequence.
In order to furthermore learn about this type of arithmetic sequence, he began playing around with making operations with it. He got an array $$$v$$$, of length $$$n$$$, and given the first four elements and two indices $$$i$$$ and $$$j$$$, $$$(i \lt j)$$$, he'd add the elements of the sequence onto the array. Of course he'd add them in order, with the first element being added to index $$$i$$$, and the $$$(j - i)^{th}$$$ element being added to index $$$j$$$. However, he'd perform these operations given some restrictions:
Deaga does this many times and ends up getting bored doing all the calculations, and asks for your help to speed things up! Based on the initially empty array, he performs $$$q$$$ queries, in which one will add a certain sequence to a certain range of the array, and another one which will ask the sum of elements of a certain range.
Such graphic depicts what a third-order arithmetic progression looks like The first line of the input contains two integers, $$$n$$$ and $$$q$$$, $$$(4 \leq n \leq 2 \times 10^5)$$$, $$$(1 \leq q \leq 2 \times 10^5)$$$ — the size of the empty array and the amount of queries.
The next $$$q$$$ lines will contain information about the $$$i^{th}$$$ query done by Deaga. Each line will start with an integer $$$t_i$$$, $$$(1 \leq t_i \leq 2)$$$ — the type of query.
For every query in which $$$t_i = 2$$$, print out the sum of the elements in the range $$$[l, r]$$$. Since the sum can be very large, print out the sum modulo Deaga's favorite prime number: 1000696969.
7 81 1 7 1 2 11 342 1 12 2 22 3 32 4 42 5 52 6 62 7 7
1 2 11 34 77 146 247
15 81 1 10 2 545 2224 51772 1 52 6 102 1 101 8 15 61 19 3 12 1 102 11 152 14 15
17490 172265 189755 189838 1000696814 1000696821
| Название |
|---|


