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

建议使用的浏览器:

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

5869:Different GCD Subarray Query

题目描述
This is a simple problem. The teacher gives Bob a list of problems about GCD (Greatest Common Divisor). After studying some of them, Bob thinks that GCD is so interesting. One day, he comes up with a new problem about GCD. Easy as it looks, Bob cannot figure it out himself. Now he turns to you for help, and here is the problem:
  
  Given an array $a$ of $N$ positive integers $a_1, a_2, \cdots a_{N-1}, a_N$; a subarray of $a$ is defined as a continuous interval between $a_1$ and $a_N$. In other words, $a_i, a_{i+1}, \cdots, a_{j-1}, a_j$ is a subarray of $a$, for $1\le i\le j\le N$. For a query in the form $(L, R)$, tell the number of different GCDs contributed by all subarrays of the interval $[L, R]$.
  
输入解释
There are several tests, process till the end of input.
  
  For each test, the first line consists of two integers $N$ and $Q$, denoting the length of the array and the number of queries, respectively. $N$ positive integers are listed in the second line, followed by $Q$ lines each containing two integers $L,R$ for a query.

You can assume that
  
    $1\le N,Q\le100000$
    
   $1\le a_i\le1000000$
输出解释
For each query, output the answer in one line.
输入样例
5 3
1 3 4 6 9
3 5
2 5
1 5
输出样例
6
6
6
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5869

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

共提交 0

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