Codeforces Round 373 (Div. 1)
C
Sasha and Array
Codeforces
2300
原题
← AD →
翻译中…

Sasha has an array of integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. You have to perform $*m*$ queries. There might be queries of two types:

翻译中…
  1. 1 l r x — increase all integers on the segment from $*l*$ to $*r*$ by values $*x*$;
  2. 2 l r — find image, where $*f*(*x*)$ is the $*x*$-th Fibonacci number. As this number may be large, you only have to find it modulo $10^{9} + 7$.
翻译中…

In this problem we define Fibonacci numbers as follows: $*f*(1) = 1$, $*f*(2) = 1$, $*f*(*x*) = *f*(*x* - 1) + *f*(*x* - 2)$ for all $*x* > 2$.

翻译中…

Sasha is a very talented boy and he managed to perform all queries in five seconds. Will you be able to write the program that performs as well as Sasha?

翻译中…

Input

翻译中…

The first line of the input contains two integers $*n*$ and $*m*$ ($1 ≤ *n* ≤ 100 000$, $1 ≤ *m* ≤ 100 000$) — the number of elements in the array and the number of queries respectively.

翻译中…

The next line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$).

翻译中…

Then follow $*m*$ lines with queries descriptions. Each of them contains integers $*tp*_{*i*}$, $*l*_{*i*}$, $*r*_{*i*}$ and may be $*x*_{*i*}$ ($1 ≤ *tp*_{*i*} ≤ 2$, $1 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ *n*$, $1 ≤ *x*_{*i*} ≤ 10^{9}$). Here $*tp*_{*i*} = 1$ corresponds to the queries of the first type and $*tp*_{*i*}$ corresponds to the queries of the second type.

翻译中…

It's guaranteed that the input will contains at least one query of the second type.

翻译中…

Output

翻译中…

For each query of the second type print the answer modulo $10^{9} + 7$.

翻译中…

Note

翻译中…

Initially, array $*a*$ is equal to $1$, $1$, $2$, $1$, $1$.

翻译中…

The answer for the first query of the second type is $*f*(1) + *f*(1) + *f*(2) + *f*(1) + *f*(1) = 1 + 1 + 1 + 1 + 1 = 5$.

翻译中…

After the query 1 2 4 2 array $*a*$ is equal to $1$, $3$, $4$, $3$, $1$.

翻译中…

The answer for the second query of the second type is $*f*(3) + *f*(4) + *f*(3) = 2 + 3 + 2 = 7$.

翻译中…

The answer for the third query of the second type is $*f*(1) + *f*(3) + *f*(4) + *f*(3) + *f*(1) = 1 + 2 + 3 + 2 + 1 = 9$.

翻译中…

样例

Input #1
5 4
1 1 2 1 1
2 1 5
1 2 4 2
2 2 4
2 1 5
Output #1
5
7
9
InputCopy OutputCopy
题目信息
题号
718C
时间限制
5 s
内存限制
256 MB
标签
数据结构
数学
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。