#include #include #include using namespace std; int B[100100][303] = {}; int main() { vector ps; vector b(2001); fill(b.begin(), b.end(), true); for (int p = 2; p < 2000; p++) if (b[p]) { ps.push_back(p); for (int q = p*p; q < 2000; q += p) b[q] = false; } assert(ps.size() == 303); int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; for (int k = 0; k < ps.size() && a > 1; k++) { int p = ps[k], e = 0; while (a % p == 0) { e++; a /= p; } if (e > 0) for (int j = i+1; j <= n; j += j&-j) B[j][k] += e; } } int q; cin >> q; while (q--) { int l, r, x; cin >> x >> l >> r; for (int k = 0; k < ps.size(); k++) { int p = ps[k], e = 0; if (x % p == 0) { for (int j = r; j > 0; j -= j&-j) e += B[j][k]; for (int j = l-1; j > 0; j -= j&-j) e -= B[j][k]; while (e > 0 && x % p == 0) x /= p, e--; } } cout << (x == 1 ? "Yes" : "NO") << endl; } }