#D. 结束(end)

    Type: Default File IO: end 5000ms 1024MiB

结束(end)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

image

题目描述

Misaki Mei 给了你一个序列 aa,每次询问给一个区间 [l,r][l,r]

查询 li,jrl \leq i,j\leq r,且 aia_iaja_j 倍数的二元组 (i,j)(i,j) 的个数。

输入格式

第一行两个整数表示 n,mn,m

第二行 nn 个整数表示序列 aa

之后 mm 行,每行两个整数 l,rl,r 表示一次询问。

输出格式

对于每个询问,输出一行一个整数表示答案。

样例 11

【样例输入】

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

【样例输出】

1
3
10

样例 22

见下发 ex_end2.in/ans\textit{ex\_end2.in/ans}

该样例满足测试点 22 的性质。

数据范围

对所有数据 1ain1\leq a_i\leq n1n5×1051\leq n\leq 5\times 10^5

测试点编号 n,qn,q\leq 特殊性质
11 500500
22 50005000
33 5×1055\times 10^5 aia_i[1,n][1,n] 中随机生成
44 10510^5
55 5×1055\times 10^5

NOIP 模拟赛(八)pretest

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2024-8-22 7:45
End at
2024-8-22 12:15
Duration
4.5 hour(s)
Host
Partic.
22