## Complex Queries

Time Limit: 1 sec
Memory Limit: 756 MB
Attempts: 28
Accuracy: 3.57%
Author: Akashdeep Goel

Given an array of N complex numbers (a + bi) where i is the square root of (-1), you have to handle Q queries:

- 1 u v : Report the sum of all the complex numbers from index [u,v]. The output should be of the form a b where a = (Real part of summation)%10^9+7 and b = (Complex part of summation)%10^9+7

- 2 u v a b : Scale and Rotate and graph in such a way that the origin remains at the same spot, but the point (1,0) converges to the point (a+bi). This effect should be applicable to all the points from the index [u,v] (i.e. these points get scaled and rotated the same way as 1+0i)

### Input:

The first line contains the value N

The next line contains 2N integers in the form a1 b1 a2 b2 a3 b3... where ai bi denote the the i-th complex number

The next line contains the value Q

the next Q lines contain all the queries in the above mentioned form

### Output:

For all the queries of type 1, output two integers a and b where a = (Real part of summation)%10^9+7 and b = (Complex part of summation)%10^9+7

### Sample Input:

3

1 1 2 2 3 3

3

1 1 3

2 2 3 4 5

1 1 2

### Sample Output:

6 6

1000000006 19

### Constraints:

1 <= N <= 10^5

1 <= ai,bi <= 10^9

1 <= Q <= 10^5

1 <= a,b <= 10^9

1 <= u <= v <= N

ID

SUBMITTED AT

STATUS

LANGUAGE

TIME

MEMORY USED

USER

TIME

STATUS

LANGUAGE

TIME

MEMORY USED

1 year ago

cpp14

0.61 sec

12968 KB