HRY and fibonacci
题号:NC25395
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

HRY is a pupil. He has just learned about Fibonacci sequence recently, and he made some new sequences : 


fib(i) means the ith element in the Fibonacci sequence :
 

At first this problem is to calculate fid(n), but that is too easy. So after discussing with 10256, they changed the problem:
Given a positive integer array a_1, a_2,...,a_n, perform the following two types of operations:

1. Given l,r,x, for all , execute
2. Given l,r, calculate

输入描述:

The first line of the input contains an integer n, indicating the length of the array.

The second line contains n positive integers separated by spaces, indicating .

The third line contains an integer Q, indicating the number of operations.

For the next Q lines, it is either , indicating the first type of operation, or , indicating the second type of operation.

All values in input are integers.

输出描述:

For each operation of second type, output.
示例1

输入

复制
3
1 2 3
6
2 1 3
1 1 3 1
2 1 3
1 1 1 2
1 2 2 3
2 1 3

输出

复制
11
24
74