CF475D.CGCDSSQ
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given a sequence of integers _a_1, ..., a__n and q queries _x_1, ..., x__q on it. For each query x__i you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(a__l, a__l + 1, ..., a__r) = x__i.
is a greatest common divisor of _v_1, _v_2, ..., v__n, that is equal to a largest positive integer that divides all v__i.
给定一个整数序列 a1,…,an 和 q 个查询 x1,…,xq。对每个查询 xi,你需要统计满足 1≤l≤r≤n 且 gcd(al,al+1,…,ar)=xi 的区间对 (l,r) 的数量。
表示 v1,v2,…,vn 的最大公约数(GCD),即能整除所有 vi 的最大正整数。
输入格式
The first line of the input contains integer n, (1 ≤ n ≤ 105), denoting the length of the sequence. The next line contains n space separated integers _a_1, ..., a__n, (1 ≤ a__i ≤ 109).
The third line of the input contains integer q, (1 ≤ q ≤ 3 × 105), denoting the number of queries. Then follows q lines, each contain an integer x__i, (1 ≤ x__i ≤ 109).
输入的第一行包含一个整数 n(1 ≤ n ≤ 105),表示序列的长度。
第二行包含 n 个以空格分隔的整数 a1, …, an(1 ≤ ai ≤ 109)。
输入的第三行包含一个整数 q(1 ≤ q ≤ 3 × 105),表示查询的次数。
随后是 q 行,每行包含一个整数 xi(1 ≤ xi ≤ 109)。
输出格式
For each query print the result in a separate line.
对每个查询,在单独的一行中输出结果。
输入输出样例
输入#1
3 2 6 3 5 1 2 3 4 6
输出#1
1 2 2 0 1
输入#2
7 10 20 3 15 1000 60 16 10 1 2 3 4 5 6 10 20 60 1000
输出#2
14 0 2 2 2 0 2 2 1 1
输入解题思路,AI测评打分。不知道怎么写?