#include #include #include using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) cin >> A[i]; int mx = *max_element(A.begin(), A.end()); vector prime; for (int i = 2; i <= mx; ++i) { bool ok = true; for (int j = 2; j * j <= i; ++j) { if (i % j == 0) ok = false; } if (ok) prime.push_back(i); } vector > c(prime.size(), vector(N + 1)); for (int i = 0; i < N; ++i) { int cur = A[i]; for (int j = 0; j < prime.size(); ++j) { int cnt = (A[i] == 0 ? 100 : 0); if (A[i] >= 1) { while (cur % prime[j] == 0) cur /= prime[j], ++cnt; } c[j][i + 1] = c[j][i] + cnt; } } vector zerosum(N + 1); for (int i = 0; i < N; ++i) { zerosum[i + 1] = zerosum[i] + (A[i] == 0 ? 1 : 0); } int Q; cin >> Q; for (int i = 0; i < Q; ++i) { int P, L, R; cin >> P >> L >> R; --L; bool ok = true; for (int j = 0; j < prime.size(); ++j) { int cnt = 0; while (P % prime[j] == 0) P /= prime[j], ++cnt; if (c[j][R] - c[j][L] < cnt) ok = false; } if (P > 1) ok = false; cout << (ok || zerosum[R] != zerosum[L] ? "Yes\n" : "NO\n"); } return 0; }