import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum LIM = 2005; int N; int[] A; int Q; int[] M, L, R; void main() { auto isnp = new bool[LIM]; foreach (p; 2 .. LIM) { if (!isnp[p]) { for (int n = 2 * p; n < LIM; n += p) { isnp[n] = true; } } } int[] primes; foreach (p; 2 .. LIM) { if (!isnp[p]) { primes ~= p; } } stderr.writeln("|primes| = ", primes.length); const primesLen = cast(int)(primes.length); try { for (; ; ) { N = readInt(); A = new int[N]; foreach (i; 0 .. N) { A[i] = readInt(); } Q = readInt(); M = new int[Q]; L = new int[Q]; R = new int[Q]; foreach (q; 0 .. Q) { M[q] = readInt(); L[q] = readInt() - 1; R[q] = readInt(); } auto zero = new int[N + 1]; foreach (i; 0 .. N) { zero[i + 1] = zero[i] + ((A[i] == 0) ? 1 : 0); } auto sums = new int[][](primesLen, N + 1); foreach (h; 0 .. primesLen) { const p = primes[h]; foreach (i; 0 .. N) { int e; if (A[i] != 0) { for (int a = A[i]; a % p == 0; a /= p) { ++e; } } sums[h][i + 1] = sums[h][i] + e; } } foreach (q; 0 .. Q) { bool ans; if (zero[R[q]] - zero[L[q]] > 0) { ans = true; } else { ans = true; int m = M[q]; foreach (h; 0 .. primesLen) { const p = primes[h]; int e; for (; m % p == 0; m /= p) { ++e; } ans = ans && (sums[h][R[q]] - sums[h][L[q]] >= e); } ans = ans && (m == 1); } writeln(ans ? "Yes" : "NO"); } } } catch (EOFException e) { } }