CF1718F.Burenka, an Array and Queries
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Eugene got Burenka an array a of length n of integers from 1 to m for her birthday. Burenka knows that Eugene really likes coprime integers (integers x and y such that they have only one common factor (equal to 1)) so she wants to to ask Eugene q questions about the present.
Each time Burenka will choose a subsegment al,al+1,…,ar of array a, and compute the product of these numbers p=al⋅al+1⋅…⋅ar. Then she will ask Eugene to count the number of integers between 1 and C inclusive which are coprime with p.
Help Eugene answer all the questions!
尤金送给布伦卡一个长度为 n 的数组 a 作为生日礼物,其中每个元素都是从 1 到 m 的整数。布伦卡知道尤金非常喜欢互质整数(即两个整数 x 和 y 的唯一公共因数为 1),因此她打算向尤金提出 q 个关于该数组的问题。
每次,布伦卡会选择数组 a 的一个子段 al,al+1,…,ar,并计算这些数的乘积 p=al⋅al+1⋅…⋅ar。接着,她会请尤金计算在 1 到 C(含端点)之间与 p 互质的整数的个数。
请帮助尤金回答所有这些问题!
输入格式
In the first line of input there are four integers n, m, C, q (1≤n,q≤105, 1≤m≤2⋅104, 1≤C≤105) — the length of the array a, the maximum possible value of ai, the value C, and the number of queries.
The second line contains n integers a1,a2,…,an (1≤ai≤m) — the array a .
In the next q lines the queries are given. Each query consists of two integers l and r (1≤l≤r≤n).
输入的第一行包含四个整数 n、m、C、q(1≤n,q≤105,1≤m≤2⋅104,1≤C≤105)——分别表示数组 a 的长度、ai 的最大可能值、数值 C 以及查询次数。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤m)——即数组 a。
接下来 q 行给出查询。每个查询包含两个整数 l 和 r(1≤l≤r≤n)。
输出格式
Print q integers — the answers to Burenka's queries.
输出 q 个整数——即布伦卡各个查询的答案。
输入输出样例
输入#1
5 5 5 3 1 2 3 2 5 1 1 2 4 4 5
输出#1
5 2 2
说明/提示
Here's an explanation for the example:
- in the first query, the product is equal to 1, which is coprime with 1,2,3,4,5.
- in the second query, the product is equal to 12, which is coprime with 1 and 5.
- in the third query, the product is equal to 10, which is coprime with 1 and 3.
以下是该示例的解释:
- 在第一个查询中,乘积等于 1,它与 1,2,3,4,5 均互质。
- 在第二个查询中,乘积等于 12,它与 1 和 5 互质。
- 在第三个查询中,乘积等于 10,它与 1 和 3 互质。
输入解题思路,AI测评打分。不知道怎么写?