|
||||||||||
Naive OperationsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 7029 Accepted Submission(s): 2832 Problem Description In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permutation of 1 to n. Initially a is filled with zeroes. There are two kind of operations: 1. add l r: add one for $a_l,a_{l+1}...a_r$ 2. query l r: query $\sum_{i=l}^r \lfloor a_i / b_i \rfloor$ Input There are multiple test cases, please read till the end of input file. For each test case, in the first line, two integers n,q, representing the length of a,b and the number of queries. In the second line, n integers separated by spaces, representing permutation b. In the following q lines, each line is either in the form 'add l r' or 'query l r', representing an operation. $1 \leq n,q \leq 100000$, $1 \leq l \leq r \leq n$, there're no more than 5 test cases. Output Output the answer for each 'query', each one line. Sample Input
Sample Output
Source | ||||||||||
|