問題一覧 > 通常問題

No.854 Fair Apple Distribution

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 3.153秒 / メモリ制限 : 315 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 75
作問者 : CuriousFairy315 / テスター : tatyam
お気に入りにしたユーザー ProblemId : 2747 / 自分の提出
問題文最終更新日: 2019-07-27 00:01:08
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 218 (順位表) の他の問題:

Problem Statement

The fairy has $N$ boxes, and the $i$-th box contains $A_i$ apples.
The fairy is about to hold a banquet with many fairy friends, and plans to open some of the boxes and distribute the apples.
The fairy has come up with $Q$ plans. In the $i$-th plan, $P_i$ fairies will come, and the fairy intends to open all the boxes in $[L_i, R_i]$ and share the apples inside.
At this time, by the power of magic, $\prod_{j=L_i}^{R_i} A_j$ apples can be taken out.
For each plan, output Yes if the apples taken out can be distributed equally among exactly $P_i$ fairies, and NO if there will inevitably be a remainder.

Input

$N$
$A_1$ $A_2$ $\cdots$ $A_N$
$Q$
$P_1$ $L_1$ $R_1$
$P_2$ $L_2$ $R_2$
$\vdots$
$P_Q$ $L_Q$ $R_Q$

Constraints
・$1 \leq N, Q \leq 10^5$
・$0 \leq A_i \leq 2 \times 10^3$
・$1 \leq L_i \leq R_i \leq N$
・$1 \leq P_i \leq 10^9$
・All inputs are integers

Output

On the $i$-th line, output Yes if $\prod_{j=L_i}^{R_i} A_j$ is divisible by $P_i$, and NO if it is not.
Print a newline at the end.

Sample

Sample 1
Input
3
6 4 6
1
2 2 3
Output
Yes

The product of the interval $[2, 3]$ is $24$, which is divisible by $2$, so output Yes.

Sample 2
Input
5
1 1 1 1 1
2
2 2 4
1 2 4
Output
NO
Yes

For the first line, the product of the interval $[2, 4]$ is $1$, which is not divisible by $2$, so output NO.
For the second line, the product of the interval $[2, 4]$ is $1$, which is divisible by $1$, so output Yes.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。