P5309 [Ynoi2011] Initialization

Background

As for me... when did I begin to exist here? Since when... did I become me? Come to think of it, I don't seem to have any memory from birth? So does that mean the “me” of tomorrow and the “me” of today are the same being? Or rather... how do we define this “self”? Does this “self” really exist? If it does... then what is its meaning? Wait... how do we define “meaning”? Meaning... meaning... meaning... meaning... meaning... meaning... meaning... meaning... ... He, of course, couldn't figure any of this out. So, naturally, he went to ask the adults, just like a child should. “Dad, what is the meaning of living?” “You’ll understand when you grow up. For now, just study hard.” “Mom, what is the meaning of living?” “Why is a child thinking about this? Focus on getting good grades first.” “Teacher, what is the meaning of living?” “Study hard, get good grades, get into a good university, find a good job, and then make lots of money.” I see—that's the meaning. Even if that's the meaning, it feels so dull, so sad. But since that is the meaning, no matter how dull or sad it is, it must be pursued, because after all, it's the meaning~! So he began to study hard. With decent talent, he got into a good middle school and the best class. The future seemed bright. In fact, that's exactly what he thought then (laughs). [Remember to add an illustration, content TBD]. Since this is Ynoi and not a place for the setter to write nonsense, you need to solve a data structure problem:

Description

Mayuri has $n$ stars, each with a brightness $A_{i}$. Mayuri often wants to know the sum of the brightnesses of all stars in an interval $[l, r]$. But stars twinkle, so their brightness can change. At times, the brightness of stars with indices $y, y+x, y+2x, y+3x, \ldots, y+kx$ increases by $z$. It is guaranteed that $y \leq x$. Mayuri is not very good at math; please answer her queries. The answer should be taken modulo $10^{9}+7$.

Input Format

The first line contains two integers $n$ and $m$, the number of stars and the number of operations. The next line contains $n$ numbers $A_{i}$, the initial brightness values. Then follow $m$ lines. Each line starts with an integer denoting the operation type: if it is $1$, it is an update, followed by three integers $x, y, z$; if it is $2$, it is a query, followed by two integers $l, r$.

Output Format

For each query operation, output one line with the answer.

Explanation/Hint

Idea: yanQval, Solution: yanQval, Code: yanQval, Data: yanQval & nzhtl1477. Constraints: - For $10\%$ of the testdata, $n, m \leq 1000$. - For another $10\%$ of the testdata, $x>1000$. - For another $10\%$ of the testdata, $x>300$. - For another $10\%$ of the testdata, $n, m \leq 10^5$. - For $100\%$ of the testdata, $1 \leq n, m \leq 2 \times 10^5$, $1 \leq y \leq x \leq n$, $1 \leq l \leq r \leq n$, $0 \leq A_i, z \leq 10^{9}+7$. Translated by ChatGPT 5