#include #include using namespace std; int PRIME_SIZE; int MAX_APPLE = 2000; int main() { vector prime; for (int i = 2; i <= MAX_APPLE; i++) { bool flag = true; for (auto x:prime) { if (x * x > i)break; if (i % x == 0)flag = false; } if (flag)prime.push_back(i); } PRIME_SIZE = prime.size(); vector> factoring(MAX_APPLE + 1, vector(PRIME_SIZE)); for (int i = 1; i <= MAX_APPLE; i++) { int x = i; for (int j = 0; j < PRIME_SIZE; j++) { while (x % prime[j] == 0) { x /= prime[j]; factoring[i][j]++; } } } int n; cin >> n; vector> cumulative_sum(n + 1, vector(PRIME_SIZE)); int zero_count[n + 1]; for (int i = 1; i <= n; i++) { int now; cin >> now; for (int j = 0; j < PRIME_SIZE; j++) cumulative_sum[i][j] = cumulative_sum[i - 1][j] + factoring[now][j]; zero_count[i] = zero_count[i - 1] + (now == 0); } int q; cin >> q; for (int i = 0; i < q; i++) { int p, l, r; cin >> p >> l >> r; vector needed(PRIME_SIZE); for (int j = 0; j < PRIME_SIZE; j++) { while (p % prime[j] == 0) { p /= prime[j]; needed[j]++; } } if (p != 1) { cout << (zero_count[r] - zero_count[l - 1] ? "Yes" : "NO") << endl; continue; } bool ret = true; for (int j = 0; j < PRIME_SIZE; j++) { if (cumulative_sum[r][j] - cumulative_sum[l - 1][j] < needed[j]) ret = false; } cout << (ret ? "Yes" : "NO") << endl; } return 0; }