CF1718F.Burenka, an Array and Queries
普及/提高-
通过率:0%
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!
输入格式
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 ).
输出格式
Print q integers — the answers to Burenka's queries.
输入输出样例
输入#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 .