Practice: At the beginning, I did not pay attention to integer data for LL processing ..
# Include <cstdio> # include <cstring> # define left L, M, x <1 # define right m + 1, R, x <1 | 1 typedef long ll; const int LMT = 100003; // bad programming habits. Ll sum [5] [12] [LMT <2]; int Z; ll query (int l, int R, int L, int R, int X) {If (L <= L & R <= r) return sum [Z-2] [(L-L + 1) % (z <1)-2)] [X]; int M = (L + r)> 1; ll res = 0; If (L <= m) RES + = query (L, R, left ); if (r> m) RES + = query (L, R, right); Return res;} void Update (INT op, int POs, int L, int R, int X) {If (L = r) {int I, j; for (I = 2; I <= 6; ++ I) for (j = 0; j <(I <1)-2; ++ J) if (j> I) sum [I-2] [J] [x] = op * (LL (I) <1)-j ); // here, else if (j> 0 & J <= I) Su M [I-2] [J] [x] = LL (1) * op * j; else sum [I-2] [J] [x] = LL (OP) <1; return;} int M = (L + r)> 1, I, j, Le = m-L + 1; if (Pos <= m) update (OP, POs, left); else Update (OP, POs, right); for (I = 2; I <= 6; ++ I) for (j = 0; j <(I <1)-2; ++ J) sum [I-2] [J] [x] = sum [I-2] [J] [x <1] + sum [I-2] [(j + le) % (I <1)-2)] [x <1 | 1];} int main (void) {// two % d are written at the beginning... Int L, R, I, n, T, V, X; scanf ("% d", & N); for (I = 1; I <= N; ++ I) {scanf ("% d", & X); Update (X, I, 1, n, 1);} scanf ("% d ", & T); While (t --) {scanf ("% d", & X); if (1 = x) {scanf ("% d ", & L, & V); Update (v, L, 1, n, 1);} else {scanf ("% d", & L, & R, & Z); printf ("% i64d \ n", query (L, R, 1, n, 1) ;}} return 0 ;}