int main()
{
	#ifdef LOCAL
//	freopen("1008.in", "r", stdin);
//	freopen("out.txt", "w", stdout);
	#endif
	
	int T;
	scanf("%d", &T);
	for(int ck=1; ck<=T; ck++)
	{
		scanf("%d%d", &N, &M);
		for(int i=1; i<=N; i++) scanf("%d", &A[i]);
		tree.len=N;
		tree.build();
		for(int i=1,opt,l,r,x; i<=M; i++)
		{
			scanf("%d%d%d", &opt, &l, &r);
			if(opt==1) {scanf("%d", &x); tree.add(l,r,x);}
			if(opt==2) {tree.rsqrt(l,r);}
			if(opt==3) {printf("%lld\n", tree.sum(l,r));}
//			PCUT;
		}
	}
	return 0;
}
Beispiel #2
0
int main()
{
    ifstream fin("sum.in");
    ofstream fout("sum.out");
    int n = 0, k = 0;
    fin >> n >> k;
    int *values = new int[n];
    for (int i = 0; i < n; i++)
    {
        values[i] = 0;
    }
    SegmentTree rsq = SegmentTree(n, values);
    for (int i = 0; i < k; i++)
    {
        char c;
        int a, b;
        fin >> c >> a >> b;
        if (c == 'A')
            rsq.update(a - 1, b);
        else
            fout << rsq.sum(a - 1, b - 1) << "\n";
    }
    return 0;
}