// // Created by yamunaku on 2019/07/26. // #include using namespace std; #define rep(i, n) for(int i = 0; i < (n); i++) #define repl(i, l, r) for(int i = (l); i < (r); i++) #define per(i, n) for(int i = ((n)-1); i >= 0; i--) #define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--) #define all(x) (x).begin(),(x).end() #define MOD9 998244353 #define MOD1 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 #define SP <<" "<< #define CYES cout<<"Yes"< vi; typedef vector> mti; typedef vector vl; typedef vector> mtl; struct SegmentTree { private: int n; vector node; public: void init(vi &v) { int sz=v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, 0); for(int i=0; i=0; i--) node[i] = node[2*i+1]+node[2*i+2]; } int getsum(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return 0; if(a <= l && r <= b) return node[k]; int vl = getsum(a, b, 2*k+1, l, (l+r)/2); int vr = getsum(a, b, 2*k+2, (l+r)/2, r); return vl+vr; } }; struct SegmentTree2{ private: int n; vector node; public: void init(vi &v) { int sz=v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, IINF); for(int i=0; i=0; i--) node[i] = min(node[2*i+1],node[2*i+2]); } int getmin(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return IINF; if(a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2*k+1, l, (l+r)/2); int vr = getmin(a, b, 2*k+2, (l+r)/2, r); return min(vl,vr); } }; int main(){ CFS; vi isp(2001,1); isp[0]=isp[1]=0; rep(i,2001){ if(isp[i]){ for(int j=i+i;j<2001;j+=i){ isp[j]=0; } } } vi prime; rep(i,2001) if(isp[i]) prime.push_back(i); int pn=prime.size(); cout << pn << endl; vector seg(pn); int n; cin >> n; vi a(n); rep(i,n) cin >> a[i]; mti paa(pn,vi(n,0)); rep(i,n){ if(a[i]==0) continue; rep(j,pn){ while(a[i]%prime[j]==0){ a[i]/=prime[j]; paa[j][i]++; } if(a[i]==1) break; } } rep(i,pn){ seg[i].init(paa[i]); } SegmentTree2 seg2; seg2.init(a); int q; cin >> q; rep(_,q){ int p,l,r; cin >> p >> l >> r; if(seg2.getmin(l-1,r)==0){ CYES; continue; } rep(i,pn){ if(p%prime[i]==0){ int cnt=0; while(p%prime[i]==0){ p/=prime[i]; cnt++; } if(cnt>seg[i].getsum(l-1,r)){ CNO; goto next; } if(p==1) break; } } if(p==1) CYES; else CNO; next:; } return 0; }