GSS4 - Can you answer these queries IV

You are given a sequence A of N(N <= 100,000) positive integers. There sum will be less than 1018. On this sequence you have to apply M (M <= 100,000) operations:

(A) For given x,y, for each elements between the x-th and the y-th ones (inclusively, counting from 1), modify it to its positive square root (rounded down to the nearest integer).

(B) For given x,y, query the sum of all the elements between the x-th and the y-th ones (inclusively, counting from 1) in the sequence.


Multiple test cases, please proceed them one by one. Input terminates by EOF.

For each test case:

The first line contains an integer N. The following line contains N integers, representing the sequence A1..AN.
The third line contains an integer M. The next M lines contain the operations in the form "i x y".i=0 denotes the modify operation, i=1 denotes the query operation.


For each test case:

Output the case number (counting from 1) in the first line of output. Then for each query, print an integer as the problem required.

Print an blank line after each test case.

See the sample output for more details.


1 2 3 4 5
1 2 4
0 2 4
1 2 4
0 4 5
1 1 5
10 10 10 10
1 1 4
0 2 3
1 1 4

Case #1:

Case #2:

hide comments
o_oaikin: 2021-02-17 02:49:29

Notice every integres using long long , Not only the sum!!

o_oaikin: 2021-02-17 02:47:25

slove it! Nice!

o_oaikin: 2021-02-15 10:41:27

Damn it!

aryan12: 2020-10-04 13:05:22

AC in the second go!! Missed the (l > r) constraint in queries.

pcwallace: 2020-04-29 07:55:23

anyone get AC in java

pareksha: 2020-04-28 09:26:02

AC in one go, thanks to the comments!

asanyal122: 2020-04-21 14:37:33

for queries and updates take care of if x>y: swap(x,y)

ks1999: 2020-04-16 23:10:28

use ios_base::sync_with_stdio(false);
in your code if you are using cin and cout. Faster than scanf and printf in my case.

zakir068: 2020-03-19 11:59:42

next solve chef DIVMAC

sundaru: 2020-02-05 21:43:30

the concept is good but framing and judging are poor af.

Added by:Fudan University Problem Setters
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL JS-RHINO PERL6
Resource:Own problem, used in ACM/ICPC Regional Contest, Shanghai 2011 preliminary