### Statement

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≤n,q≤100000$, $1≤l≤r≤n$, there’re no more than 5 test cases.

### Code

#include
#define ls (p<<1)
#define rs (p<<1|1)
#define len (r-l+1)
#define mid ((l+r)>>1)
#define maxn 100100
using namespace std;
struct Node{
}tree[maxn<<2];
int n,m,b[maxn];
void pushup(int p){
tree[p].sum=tree[ls].sum+tree[rs].sum;
tree[p].maxa=max(tree[ls].maxa,tree[rs].maxa);
tree[p].minb=min(tree[ls].minb,tree[rs].minb);
}
void pushdown(int p){
}
void build(int l,int r,int p){
if (l==r){
tree[p].minb=b[l];
return;
}
build(l,mid,ls);
build(mid+1,r,rs);
pushup(p);
}
void update(int l,int r,int L,int R,int p){
if (l>R||r=L&&r<=R){
tree[p].maxa++;
if (tree[p].maxaR||r=L&&r<=R) return tree[p].sum;
return query(l,mid,L,R,ls)+query(mid+1,r,L,R,rs);
}
int main(){
ios::sync_with_stdio(false);
while(cin>>n>>m){
memset(tree,0,sizeof(tree));
for (int i=1;i<=n;i++)
cin>>b[i];
build(1,n,1);
while(m--){
string op;int x,y;
cin>>op>>x>>y;
else cout<
 
 Share 【安利】我的音乐收藏 OneDrive 分享链接 [https://drive.xgzepto.cn/%E9%9F%B3%E4%B9%90%… 11 Oct 2018 【Quest OJ Emulate 9 / 19】Deep ♂ Dark ♂ Fantasy / 题解 比赛地址 [https://questoj.cn/contest/17] Deep [https://questoj.cn/contest/17/… 20 Sep 2018 
 
 
 Zepto's © 2024 Data & privacy Contact → Published with Ghost • Theme Attila • System theme 
 $(document).ready(function () { var viewport =$(window); var post = $('.post-content'); // Responsive videos with fitVids post.fitVids(); // Format code blocks and add line numbers function codestyling() {$('pre code').each(function(i, e) { // Code highlight hljs.highlightElement(e); // No lines for plain text blocks if (!$(this).hasClass('language-text')) { var code =$(this); // Calculate amount of lines var lines = code.html().split(/\n(?!$)/g).length; var numbers = []; if (lines > 1) { lines++; } for (i = 1; i < lines; i++) { numbers += '<span class="line" aria-hidden="true">' + i + '</span>'; } code.parent().append('<div class="lines">' + numbers + '</div>'); } }); } codestyling(); // Reading progress bar on window top function readingProgress() { var postBottom = post.offset().top + post.height(); var viewportHeight = viewport.height(); var progress = 100 - (((postBottom - (viewport.scrollTop() + viewportHeight) + viewportHeight / 3) / (postBottom - viewportHeight + viewportHeight / 3)) * 100);$('.progress-bar').css('width', progress + '%'); (progress > 100) ? $('.progress-container').addClass('complete'):$('.progress-container').removeClass('complete'); } readingProgress(); // Trigger reading progress viewport.on({ 'scroll': function() { readingProgress(); }, 'resize': function() { readingProgress(); }, 'orientationchange': function() { readingProgress(); } }); });