Super Power Of 2s
Practice
4.3 (3 votes)
Approved
Data structures
Hard
Open
Trees
Problem
22% Success 1308 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Maggu loves to create problems involving queries. This time ,he has created one for you.
Given an array containing n elements and maggu asked you two types of queries.

type 0 : l r
type 1 : l r

Explanation:
type 0 : add 2^1 to l th element, 2^2 to the (l+1) th element , 2^3 ot the (l+2) th element and so on upto r th element.
type 1: you are asked to print the sum of all the elements in range[l,r].

INPUT:
The first line contains the integer n denoting the size of array.This line is followed by n integers. After this line integer m is present denoting the number of queries. M lines follow each line containing the three integers the type and l and r.

OUTPUT:
For each query of type 1 print the result in a new line.

CONSTRAINTS:
1<=n<=210^5
1<=A[i]<=10^9
1<=m<=2
10^5
0<=type<=1
1<=l<=r<=n

Note:
answer to a query can be very large therefore print answer mod 10^9+7

Large I/O files so use scanf/printf instead of cin/cout.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
1 votes
Tags:
DatastructuresSegment TreesXORAdvanced Data StructuresData StructuresModular exponentiationSegment treeModulo arithmetic
Points:50
3 votes
Tags:
ApprovedData StructuresHardSegment Trees
Points:50
3 votes
Tags:
Inclusion-exclusionData StructuresSegment TreesAdvanced Data StructuresBasic ProgrammingNumber theoryCombinatoricsMath