This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include <cstdio>
#define endl "\n"
/*/*(last choice)*/ #define int long long
#define all(x) x.begin(), x.end()
#define ll long long
#define tsts int t; cin>>t; while(t--)
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
int tree[10000005];
void update(int l, int r, int idx, int val, int node=1)
{
    if(l>idx || r<idx)
        return;
    if(l==r)
    {
        tree[node]=val;
        return;
    }
    int mid=(l+r)/2;
    update(l,mid,idx,val,node*2);
    update(mid+1,r,idx,val,node*2+1);
    tree[node]=tree[node*2]+tree[node*2+1];
}
int gett(int l, int r, int ul, int ur, int node=1)
{
    if(l>ur || r<ul)
        return 0;
    if(l>=ul && r<=ur)
        return tree[node];
    int mid=(l+r)/2;
    return (gett(l,mid,ul,ur,node*2) + gett(mid+1,r,ul,ur,node*2+1));
}
signed main()
{
    start
    //freopen("codeblocksinput.txt", "w", stdout);
    int n,q,k;
    cin>>n>>q>>k;
    vector<int>v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        update(0,1e6,i,v[i]);
    }
    while(q--)
    {
        int x, l ,r;
        cin>>x>>l>>r;
        if(x==1)
        {
            v[l-1]=r;
            update(0,1e6,l-1,r);
        }
        else if(x==2)
        {
            if(k==1)
                continue;
            for(int i=l-1 ;i<=r-1; i++)
                update(0,1e6,i,v[i]/k),v[i]/=k;
        }
        else
        {
            cout<<gett(0,1e6,l-1,r-1)<<endl;
        }
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |