• Bio

    AC:Answer Coarse,粗劣的答案。

    WA:Wonderful Answer,好答案。

    TLE:Time Limit Enough,时间充裕。

    MLE:Memory Limit Enough,内存充裕。

    CE:Compile Easily,轻松通过编译。

    RE:Run Excellently,完美运行。

    UKE:Unbelievably Keep Excellent,难以置信地保持优秀。

    OLE:Output Limit Excellently,完美的输出。

    PC:Perfect Compile,完美的编译

    !五彩斑斓!

    1.线段树做A+B Problem

    #include <iostream>
    using namespace std;
    typedef long long LL;
    const int MAXN = 1e5 + 10;
    const int LOG = 20;
    int n;
    LL a[MAXN*LOG] = {0};
    LL d[MAXN*LOG] = {0};
    void pushdown(int s,int t,int p){
    	a[p] += d[p] * (t-s+1);
    	if (s<t){
    		d[p*2]+= d[p];
    		d[p*2+1] += d[p];
    	} 
    	d[p] = 0;
    }
    LL query(int l,int r,int s,int t,int p){
    	pushdown(s,t,p);
    	if (s>=l && t<=r)return a[p];
    	LL res = 0;
    	int mid = (s+t)/2;
    	if (l<=mid)res += query(l,r,s,mid,p*2);
    	if (r>=mid+1)res += query(l,r,mid+1,t,p*2+1);	 
    	return res; 
    }
    void update(int l,int r,int s,int t,int p,LL k){ 
    	if (s>=l && t<=r){
    		d[p]+=k;
    		return;
    	}
    	int mid = (s+t)/2;
    	if (l<=mid)update(l,r,s,mid,p*2,k);
    	if (r>=mid+1)update(l,r,mid+1,t,p*2+1,k);
    	pushdown(s,t,p);
    	a[p] = a[p*2] + d[p*2]*(mid-s+1) + a[p*2+1] + d[p*2+1]*(r-mid); 
    }
    int main(){
    	n=2; 
    	int x,y;
    	cin>>x>>y;
    	update(1,1,1,n,1,x);
    	update(2,2,1,n,1,y);
    	printf("%lld\n",query(1,n,1,n,1));
    }
    

    AC

  • Recent Activities

    This person is lazy and didn't join any contests or homework.