#include #include #include #include #include #include #include #include using namespace std; using ll = long long; vector prime_vector(int n) { int m = (int)sqrt(n - 1); vector q(n); for (int i = 2; i <= m; i++) { if (q[i]) continue; for (int j = i * i; j < n; j += i) { q[j] = true; } } vector p; p.reserve(n / log(n * 0.329)); for (int i = 2; i < n; i++) { if (!q[i]) p.push_back(i); } return p; } int main() { ios::sync_with_stdio(false); cin.tie(0); auto pv = prime_vector(2000); //cout << pv.size() << endl; constexpr int m = 303; using B = array; int n; cin >> n; vector s(n + 1); for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < m; j++) { int c = 0; if (a == 0) { c = 30; } else { while (a % pv[j] == 0) { a /= pv[j]; c++; } } s[i + 1][j] = s[i][j] + c; } } int q; cin >> q; for (int h = 0; h < q; h++) { int a, l, r; cin >> a >> l >> r; l--; int b = 1; for (int j = 0; j < m; j++) { int c = 0; if (a == 0) { c = 30; } else { while (a % pv[j] == 0) { a /= pv[j]; c++; } } if (s[r][j] - s[l][j] < c) { b = 0; break; } } cout << (b ? "Yes" : "NO") << '\n'; } cout << flush; return 0; }