| 2025 GUC Winter Camp |
|---|
| Закончено |
You are given an array $$$A$$$ of length $$$N$$$.
We define the function: $$$$$$f(l, r, x) = \sum_{i=l}^{r} (A_i \bmod x),$$$$$$ where $$$A_i \bmod x$$$ denotes the remainder when $$$A_i$$$ is divided by $$$x$$$.
You will be given $$$Q$$$ queries. Each query is described by four integers $$$l, r, x_l, x_r$$$ ($$$1 \le l \le r \le N$$$, $$$1 \le x_l \le x_r \le 5 \cdot 10^4$$$).
For each query, compute: $$$$$$\sum_{x=x_l}^{x_r} f(l, r, x).$$$$$$
The first line contains two integers $$$N$$$ and $$$Q$$$ ($$$1 \le N, Q \le 5 \cdot 10^4$$$) — the length of the array and the number of queries.
The second line contains $$$N$$$ integers $$$A_1, A_2, \ldots, A_N$$$ ($$$1 \le A_i \le 5 \cdot 10^4$$$) — the elements of the array.
Each of the next $$$Q$$$ lines contains four integers $$$l, r, x_l, x_r$$$.
Print $$$Q$$$ integers — the answers to the queries in the same order as they are given.
4 15 2 8 31 3 2 4
10
5 210 4 1 7 31 5 5 52 4 1 3
10 5
| Название |
|---|


