Codeforces Round 814 (Div. 1)
F
Burenka, an Array and Queries
Codeforces
3300
原题
← E→
翻译中…

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 $a_l, a_{l + 1}, \ldots, a_r$ of array $a$, and compute the product of these numbers $p = a_l \cdot a_{l + 1} \cdot \ldots \cdot a_r$. 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!

翻译中…

Input

翻译中…

In the first line of input there are four integers $n$, $m$, $C$, $q$ ($1 \leq n, q \leq 10^5$, $1 \leq m \leq 2\cdot 10^4$, $1 \leq C \leq 10^5$) — the length of the array $a$, the maximum possible value of $a_{i}$, the value $C$, and the number of queries.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_{i} \leq m$) — the array $a$ .

翻译中…

In the next $q$ lines the queries are given. Each query consists of two integers $l$ and $r$ ($1 \leq l \leq r \leq n$).

翻译中…

Output

翻译中…

Print $q$ integers — the answers to Burenka's queries.

翻译中…

Note

翻译中…

Here's an explanation for the example:

翻译中…
  1. in the first query, the product is equal to $1$, which is coprime with $1,2,3,4,5$.
  2. in the second query, the product is equal to $12$, which is coprime with $1$ and $5$.
  3. in the third query, the product is equal to $10$, which is coprime with $1$ and $3$.
翻译中…

样例

Input #1
5 5 5 3
1 2 3 2 5
1 1
2 4
4 5
Output #1
5
2
2
InputCopy OutputCopy
题目信息
题号
1718F
时间限制
3 s
内存限制
256 MB
标签
数据结构
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。