QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 128 MB Points totaux : 100

#9035. GOSICK

Statistiques

Victorique gives you a sequence $a$, and for each query, you are given an interval $[l, r]$.

Find the number of pairs $(i, j)$ such that $l \leq i, j \leq r$ and $a_i$ is a multiple of $a_j$.

Input

The first line contains two integers $n$ and $m$.

The second line contains $n$ integers representing the sequence $a$.

The following $m$ lines each contain two integers $l$ and $r$, representing a query.

Output

For each query, output a single integer representing the answer on a new line.

Examples

Input 1

6 3
1 1 4 5 1 4
1 1
4 5
1 4

Output 1

1
3
10

Subtasks

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477

For $100\%$ of the data, $1 \leq n, m, a_i \leq 5 \times 10^5$ and $1 \leq l \leq r \leq n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.