1735.
GCDispower
时间限制 5000 ms
内存限制 64 MB
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?
输入数据
输出数据
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
\n
· \n
· · \n
· \n
· \n
· · · · · \n
· \n
· \n
· \n