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

建议使用的浏览器:

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

6711:Touma Kazusa's function

题目描述
$Touma Kazusa$ is dating with $Kitahara Haruki$. To test if $Haruki$ is a skilled man, $Kazusa$ created a function which called $Kazusa$ $function $. Its expression is as follows:

$S(l,r) = \sum_{i=l}^{r}\sum_{j=l}^{r}\varphi(gcd(a_i,a_j))lcm(a_i,a_j)$ .$l$ and $r$ are the left and right endpoints of an interval of sequence $a$, respectively.

However, because this function is really easy for $Haruki$ and $Haruki$ told $Kazusa$ the answer quickly. So $Kazusa$ strengthened the problem.

Now, $Kazusa$ will gives $Haruki$ a sequence $a$ and $q$ intervals, and for each interval, $Haruki$ should calculate $S(l,r)$.$Haruki$ still thinks it's easy for him, but he just want to date with $Kazusa$, So this problem should solved by you.

Because the value of $S(l,r)$ maybe too large, you only need output $S(l,r)$ $mod$ $2^{32}$
输入解释
There are multiple test cases. The first line of the input contain an integer $T(1 \leq T \leq 100)$, indicating the number of test cases. For each test case:

First line contains two positive integers $n(1 \leq n \leq 1e5)$ and $q(1 \leq q \leq 1e5)$ which are separated by spaces, denoting the length of sequence $a$ and the number of interval.

Second line contains $n$ positive integers $a_1$,$a_2$,$a_3$,...,$a_n$$(1\leq a_i\leq 1e7)$.

Following $q$ lines, each line contain two integers $l, r$.$(1 \leq l \leq r \leq n)$

It is guaranteed that $\sum_{n} \leq 3e5$ and $\sum_{q} \leq 3e5$, and at most two cases $n = 1e5$. When $n = 1e5$,it is guaranteed that all $a_i$ are generated randomly.
输出解释
Output $q$ lines, each line is an integer, representing the value of $S(l,r)$ $mod$ $2^{32}$.
输入样例
1
5 1
1 2 3 4 5
1 5
输出样例
199
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6711

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

共提交 0

通过率 --%
时间上限 内存上限
15000/15000MS(Java/Others) 131072/131072K(Java/Others)