#include<iostream> #include<bitset> using namespace std; // 575 const int MAX = 100001; const int MAX2 = 2001; const int PRIME = 303; // 2000までの素数 const string ERROR = "No Judge"; int main() { static int N, A[MAX], Q, P, L, R; cin >> N; if (!(1 <= N && N <= 100000)) { cout << ERROR << endl; return 0; } for (int i = 0;i < N;++ i) { cin >> A[i]; if (!(0 <= A[i] && A[i] <= 2000)) { cout << ERROR << endl; return 0; } } static int prime[PRIME], sum[PRIME][MAX], sumZero[MAX]; bitset<MAX2> sieve; // エラトステネスの篩 for (int i = 2, j = 0;i < MAX2;++ i) { if (!sieve[i]) { prime[j++] = i; for (int k = i;k < MAX2;k += i) sieve[k] = true; } } for (int i = 0;i < PRIME;++ i) sum[0][i] = 0; sumZero[0] = 0; for (int i = 0;i < N;++ i) { // 累積和 sumZero[i + 1] = sumZero[i] + (A[i] == 0 ? 1 : 0); if (A[i] != 0) for (int j = 0;j < PRIME;++ j) for (sum[j][i + 1] = sum[j][i];A[i] % prime[j] == 0;++ sum[j][i + 1], A[i] /= prime[j]); } // ここまでで前準備終わり、次に各クエリの処理 cin >> Q; if (!(1 <= Q && Q <= 100000)) { cout << ERROR << endl; return 0; } while (Q-- > 0) { cin >> P >> L >> R; bool isDiv = sumZero[R] - sumZero[L - 1] == 0; // 割り切れるかフラグ for (int i = 0;i < PRIME;++ i) { int factor = 0; while (P % prime[i] == 0) { P /= prime[i]; ++ factor; } isDiv &= sum[i][R] - sum[i][L - 1] >= factor; } if (1 <= P && P <= 1000000000 && 1 <= L && L <= R && R <= N) cout << (isDiv && P == 1 ? "Yes" : "NO") << endl; else cout << ERROR << endl; } return 0; }