2018 杭电多校2 - Naive Operations

题目链接

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\le n,q\le 100000, 1\le l\le r\le n$$$, there're no more than 5 test cases.
Output
Output the answer for each 'query', each one line.
Sample Input
5 12
1 5 2 4 3
add 1 4
query 1 4
add 2 5
query 2 5
add 3 5
query 1 5
add 2 4
query 1 4
add 2 5
query 2 5
add 2 2
query 1 5
Sample Output
1
1
2
4
4
6

【题意】
$$$a_1$$$~$$$a_n$$$最开始都是0,已知$$$b_1$$$~$$$b_n$$$,一共q次操作,add操作把$$$a_l$$$~$$$a_r$$$都加1,query操作求$$$\sum_{i=l}^{r}\lfloor a_i/b_i\rfloor$$$

【思路】

更新中...

猜你喜欢

转载自www.cnblogs.com/tobyw/p/9367690.html
今日推荐