#include <iostream> using namespace std; #include<vector> #include<string> bool iszhishu(int num) { for (int i = 2; i < num; i++) { if (num % i == 0) return false; } return true; } int main() { vector<string>ret; int n, q; cin >> n >> q; int arr[100] = {0}; for (int i = 0; i < n; i++) { cin >> arr[i]; } int l_r[200][2]; for (int i = 0; i < q; i++) { cin >> l_r[i][0]>>l_r[i][1]; } for (int i = 0; i < q; i++) { if (arr[l_r[i][1]-1] < arr[l_r[i][0]-1]) ret.push_back("no"); else if (arr[l_r[i][1]-1] == arr[l_r[i][0]-1]) ret.push_back("ok"); else { if (arr[l_r[i][1]-1] % arr[l_r[i][0]-1] != 0) ret.push_back("no"); else { if(iszhishu(arr[l_r[i][1]-1] / arr[l_r[i][0]-1])) ret.push_back("ok"); else { for (int m = l_r[i][0]; m < l_r[i][1]; m++) { if (arr[m] % arr[l_r[i][0]-1] == 0 && iszhishu(arr[m] / arr[l_r[i][0]-1])) { l_r[i][0] = m+1; } if (m == l_r[i][1] - 1) { if(arr[l_r[i][1] - 1] % arr[l_r[i][0] - 1] == 0 && iszhishu(arr[m] / arr[l_r[i][0] - 1])) ret.push_back("ok"); else ret.push_back("no"); } } } } } } for (auto& re : ret) { cout << re << endl; } return 0; }
全部评论
(0) 回帖