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

建议使用的浏览器:

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

6920:Curious

题目描述
Xiao Ming is very curious about number theory and one day his teacher gives him a very strange homework. He is provided with $n$ positive integers $a_1, a_2, \ldots, a_n$ and it is guaranteed that all numbers will be no greater than $m$. What's more, his teacher asks him $k$ questions. Each time, the teacher gives a certain number $x$ (also no greater than $m$) and ask Xiao Ming for the number of pairs $(a_i,a_j)$ that satisfy $\gcd(a_i,a_j) = x$ where $1\leq i, j \leq n$.

That is to calculate
$$\sum_{i=1}^{n}\sum_{j=1}^{n}[\gcd(a_i,a_j)=x].$$

It is very difficult for Xiao Ming to figure out the problem and he turn to you for help.
输入解释
The first line of the input contains one integer $T(1\leq T \leq 10)$ - the number of test cases. Then $T$ test cases follows.

The first line of each test case contains three integers $n , m, k$ $(1\leq n, m, k\leq 10^5)$ as described above.

The second line contains $n$ integers $a_1,a_2,\ldots, a_n$ $(1 \leq a_i \leq m)$.

Each of next $k$ lines contains a single integer $x$.
输出解释
For each test case, print the answer in one line.

Hint

For $i\neq j$, $(a_i,a_j)$ and $(a_j,a_i)$ are considered different.
输入样例
1
5 5 5
1 2 3 4 5
1
2
3
4
5
输出样例
19
3
1
1
1
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6920

最后修改于 2021-06-22T18:18:53+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)