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

建议使用的浏览器:

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

7107:GCD on Sequence

题目描述
You have a permutation $a$ of length $n$. The value of an interval $[l, r]$ is defined as follow:

$$v(l, r) = \max_{l \leq i < j \leq r}{\gcd(a_i, a_j)}$$

In mathematics, the greatest common divisor($\gcd$) of two or more integers, which are not all zeroes, is the largest positive integer that divides each of the integers. For two integers $x, y$, the greatest common divisor of $x$ and $y$ is denoted by $\gcd(x, y)$. For example, the $\gcd$ of $8$ and $12$ is $4$, that is, $\gcd(8, 12) = 4$.

You need to calculate for each $x(1 \leq x \leq n)$, how many pairs of $l, r(1 \leq l < r \leq n)$ satisfy that $v(l, r) = x$.
输入解释
This problem contains multiple test cases.

The first line contains an integer $T$ indicating the number of test cases.

For each test case, the first line contains one integer $n$ ($2 \leq n \leq 10 ^ 5$).

The second line contains $n$ integers $a_i$ ($1 \leq a_i \leq n$). It's guaranteed that $a$ is a permutation.

It's guaranteed that $\sum{n} \leq 10 ^ 6$.
输出解释
For each test case, output $n$ lines.

The i-th line contains an integer indicating the answer for $x = i$.
输入样例
1
5
1 4 3 5 2
输出样例
8
2
0
0
0

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

源链接: HDU-7107

最后修改于 2021-10-23T19:11:30+00:00 由爬虫自动更新

共提交 0

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