Five

시간 제한0.7초메모리 제한1024 MB

요약
배열에 구간 덧셈을 하고, 계수 5,4,3,2,1인 선형 점화식 x_k의 구간 합을 구한다.
난이도

어려움10점 중 8점

유형
세그먼트 트리, 동적 계획법, 행렬, 수학
정답자
아직 제출이 없습니다

문제

Due to unforeseen circumstances this task is not fifth.

A recent survey by polling agency "Ko & co" found that no one likes the numbers from 11 to 44. So we will focus on the next number, 55, and hope it does not follow the unfortunate fate of its predecessors.

Consider the following sequence in the positive and negative indices:

  • x_0=0x\_0 = 0
  • x_1=1x\_1 = 1
  • x_2=2x\_2 = 2
  • x_3=3x\_3 = 3
  • x_4=4x\_4 = 4
  • x_k+5=5×x_k+4+4×x_k+3+3×x_k+2+2×x_k+1+1×x_kx\_{k+5} = 5 \times x\_{k+4} + 4 \times x\_{k+3} + 3 \times x\_{k+2} + 2 \times x\_{k+1} + 1 \times x\_k for each integer kk.

Note that equality uniquely defines both the positive and the negative indices (e.g. x_5=40x\_5 = 40, x_6=230x\_6 = 230, …\dots and x_−1=−22x\_{-1} = -22, x_−2=33x\_{-2} = 33, …\dots)

You are given an array of nn numbers a_1,a_2,…,a_na\_1, a\_2 , \dots, a\_n. Write a program five that supports 22 types of events:

  • Query with parameters ll, rr. We want to find the value x_a_l+x_a_l+1+⋯+x_a_r=∑_i=lrx_a_ix\_{a\_l} + x\_{a\_{l+1}} + \dots + x\_{a\_r} = \sum\_{i=l}^r{x\_{a\_i}}. Since it can get very large, print the answer modulo M=108+543M = 10^8 + 543.
  • Update with parameters ll, rr, valuevalue Then the new value of a_ia\_i becomes equal to a_i+valuea\_i + value for every l≤i≤rl ≤ i ≤ r.

입력

The first line of the standard input contains the numbers nn and qq. The next line contains nn integers a_1,a_2,…,a_na\_1, a\_2 ,\dots , a\_n. Each of the following qq lines contains 33 natural numbers typetype, ll, rr.

  • If type=1type = 1, then the line is a Query.
  • If type=2type = 2, then the line is an Update and contains a further integer valuevalue.

출력

For each Query, print on a new line the answer for that query.

제한

  • 1≤n≤100,0001 ≤ n ≤ 100\\,000
  • 1≤q≤200,0001 ≤ q ≤ 200\\,000
  • 1≤l≤r≤n1 ≤ l ≤ r ≤ n
  • −M<a_i,value<M-M < a\_i , value < M

예제1

  1. 예제 1

    입력
    1 5
    1
    1 1 1
    2 1 1 -2
    1 1 1
    2 1 1 8
    1 1 1
    
    예상 출력
    1
    100000521
    1330