#include #include using namespace std; typedef long long int ll; #define LIMIT 1000001 //#define LIMIT 1300 int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); vector sieve(LIMIT); for (int i=0; i> exponents(LIMIT); for (ll i=2; i> n; vector arr(n); for (int i=0; i> arr[i]; int x = arr[i]; while (x > 1){ int divisor = sieve[x]; int exp = 0; while (x % divisor == 0){ exp++; x /= divisor; } exponents[divisor][i + 1] = exp + (--exponents[divisor].end())->second; } } cin >> q; for (int i=0; i> a >> b >> labs; //cout << "Query " << i << "\n"; bool result = true; while (labs > 1 && result) { int divisor = sieve[labs]; int exp = 0; while (labs % divisor == 0){ exp++; labs /= divisor; } int availableExp = (--exponents[divisor].upper_bound(b))->second - (--exponents[divisor].lower_bound(a))->second; result &= availableExp >= exp; //cout << "Need " << exp << " of the prime " << divisor << " and have " << availableExp << '\n'; } cout << (result ? "Yes\n" : "No\n"); } return 0; }