1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #include <cstdio> using namespace std; typedef long long LL; const int N = 8e4 + 10; int n, m, s[N]; LL mod, mn, mx, d[N]; int main() { scanf("%d%d%lld%lld%lld", &n, &m, &mod, &mn, &mx); for (char op; m; m--) { scanf("%c", &op); while (op != 'A' && op != 'Q') scanf("%c", &op); if (op == 'A') { int l, r; LL x; scanf("%d%d%lld", &l, &r, &x); d[l] += x; d[r + 1] -= x; } if (op == 'Q') { int l, r; scanf("%d%d", &l, &r); int res = 0; for (LL i = 1, t = d[1]; i <= r; t += d[++i]) if (i >= l && (t * i % mod) >= mn && (t * i % mod) <= mx) res++; printf("%d\n", res); } } for (LL i = 1, t = d[1]; i <= n; t += d[++i]) s[i] = s[i - 1] + ((t * i % mod) >= mn && (t * i % mod) <= mx); scanf("%d", &m); for (int l, r; m; m--) { scanf("%d%d", &l, &r); printf("%d\n", s[r] - s[l - 1]); } return 0; }
|