Codeforces Round 163 (Div. 2)
E
More Queries to Array...
Codeforces
2500
原题
← D→
翻译中…

You've got an array, consisting of $*n*$ integers: $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. Your task is to quickly run the queries of two types:

翻译中…
  1. Assign value $*x*$ to all elements from $*l*$ to $*r*$ inclusive. After such query the values of the elements of array $*a*_{*l*}, *a*_{*l* + 1}, ..., *a*_{*r*}$ become equal to $*x*$.
  2. Calculate and print sum image, where $*k*$ doesn't exceed $5$. As the value of the sum can be rather large, you should print it modulo $1000000007 (10^{9} + 7)$.
翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 10^{5}$), showing, how many numbers are in the array and the number of queries, correspondingly. The second line contains $*n*$ integers: $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($0 ≤ *a*_{*i*} ≤ 10^{9}$) — the initial values of the array elements.

翻译中…

Then $*m*$ queries follow, one per line:

翻译中…
  1. The assign query has the following format: "image", ($1 ≤ *l* ≤ *r* ≤ *n*; 0 ≤ *x* ≤ 10^{9}$).
  2. The query to calculate the sum has the following format: "image", ($1 ≤ *l* ≤ *r* ≤ *n*; 0 ≤ *k* ≤ 5$).
翻译中…

All numbers in the input are integers.

翻译中…

Output

翻译中…

For each query to calculate the sum print an integer — the required sum modulo $1000000007 (10^{9} + 7)$.

翻译中…

样例

Input #1
4 5
5 10 2 1
? 1 2 1
= 2 2 0
? 2 4 3
= 1 4 1
? 1 4 5
Output #1
25
43
1300
InputCopy OutputCopy
Input #2
3 1
1000000000 1000000000 1000000000
? 1 3 0
Output #2
999999986
InputCopy OutputCopy
题目信息
题号
266E
时间限制
5 s
内存限制
256 MB
标签
数据结构
数学

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