当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6102:GCDispower

题目描述
There is a mysterious organization called GCD. They get a permutation P, permutation is a sequence of length N, only consists of number 1 to N and each number appears only once.
They want to gain magic power from this permutation. For the interval [L, R] they can get power:
$\sum\limits_{i=L}^R\sum\limits_{j=i+1}^R\sum\limits_{k=j+1}^R (gcd(P[i], P[j]) == P[k]) \cdot P[k]$
Now they have M queries, for each query can you help them calculate how many power they can get?
输入解释
The first line is an integer T which indicates the case number.
And as for each case, first line is two integer N and M which indicates the length of permutation and number of query.
Next line is N integer which indicate the permutation P
Next M line, for each line is two integer L and R which indicate each query.

Limit
$1 \leq T \leq 100$
$1 \leq N, M \leq100000$
$1 \leq Pi \leq N$, for any pair $(i, j)$, $Pi \neq Pj$
$1 \leq Li \leq Ri \leq N$

About 95% test case: $1 \leq N \leq 1000$
Other test case: $1 \leq N \leq 100000$
输出解释
As for each case, you need to output M integer which indicate the answer of each query.
输入样例
2
3 1
3 2 1
1 3
6 3
6 5 4 3 2 1
1 6
2 6
3 5
输出样例
1
8
5
0
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6102

最后修改于 2020-10-25T23:28:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 65536/65536K(Java/Others)